SQLTeam.com | Weblogs | Forums

Run stored procedure manually and passing paremeters



Using SQL Server 2008 R2. I am trying to run a stored procedure manually using the below format
proc_name paramValue1, paramValue2

One my parameters has commas in it and I can't figure out the syntax to pass that parameter's value. What do I need to do it? Example

usp_My Proc, @paramValue1 = 'Me', @paramValue2 = 'City', 'State', 'Zip'



Do the following

To send "City, State, Zip" (excluding the opening and closing double-quotes)

To send "'City','State','Zip'" (excluding the opening and closing double-quotes)

To embed a single quote in a string, you have to escape it with another single quote.

Reading through your question one more time, what you want is the second one above

@paramValue2 = '''City'',''State'',''Zip'''


May just have got lost in Cut & Paste to this thread, but you could do with EXEC at the start of the line:

EXEC proc_name paramValue1, paramValue2

If your code is just the single line then your syntax is fine, but for multi-line code you need the EXEC.

Apologies if that is all obvious.