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: Friday, October 17, 2014 6:39 AM
Points: 217, Visits: 870
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, October 16, 2014 8:26 AM
Points: 58, Visits: 240
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