Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Stored Procedure execution with parameters Expand / Collapse
Author
Message
Posted Wednesday, April 17, 2013 9:47 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, April 07, 2014 3:56 AM
Points: 200, Visits: 778
Yup, just had a play...

DECLARE @TestClient varchar(11);
DECLARE @SQLString nvarchar(500);
DECLARE @ParmDefinition nvarchar(500);

SET @TestClient = 'somevalue';

SET @SQLString = N'EXEC [database].dbo.Test @Client'
SET @ParmDefinition = N'@Client varchar(10)';

EXECUTE sp_executesql @SQLString, @ParmDefinition, @Client = @TestClient;


'Only he who wanders finds new paths'
Post #1443345
Posted Wednesday, April 17, 2013 10:18 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, April 10, 2014 10:32 AM
Points: 58, Visits: 235
Thanks, Lynn, the syntax you suggested works. I seem to have confused how the parameters were defined / used. I've not used this dynamic method before, only EXECUTE('CREATE VIEW ...'), etc. to script an object creation list.

~ Jeff
Post #1443370
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse