I'm trying to run a dynamic sql query using excel to pull in a list of codes which are my variables in the query.
I'm currently trying to store my SQL procedure to call later but I'm getting an error. I'm very new to this so I'm not even sure if I'm doing this in the right place. To start, I have opened visual basic, and then went to Insert > Procedure. In that screen I have the following:
CREATE PROCEDURE society_detail
Dim code_list
AS
BEGIN
SET NOCOUNT ON;
SELECT DISTINCT client_code , client_name, security_code
FROM Connection1.table_1
WHERE client_code in (@code_list)
ORDER BY client_code
End
For reference, Connection1 is my SQL connection that is set up and connecting properly. When I try to make the connection to this procedure I get an error saying "Compile Error: Expected: End of statement" and society_detail is highlighted. Basically I'm trying to call this procedure and then fill '@code_list' with a dataset that is in excel already. Hopefully this makes sense to someone as I've been searching the internet everywhere and nothing seems to be helping. I could be totally off on what I'm trying to do. Let me know if you need any more clarifications.
Thanks!

recordset=connection.execute "exec society_detail"I'll add a good link in a moment