Hi,
I am working on a simple stored procedure that takes in a string argument , which is the name of a person e.g. Bob.
I would like to know if it is possible to set the name as 'Bob' instead of Bob, at the moment i have:
CREATE PROCEDURE myProc
@myname nvarchar(20)
DECLARE @cmdSQL nvarchar(1000)
SET @cmdSQL = 'SELECT col1, col2, col3,
(SELECT col4 WHERE name = ' + @myname + ')....etc
EXECUTE(@cmdSQL)
at the moment I am getting the subquery as
(SELECT col4 WHERE name = Bob) but I actually want
(SELECT col4 WHERE name = 'Bob')
How do i insert the '' ?
Thanks in advance,
MrPeds
I am working on a simple stored procedure that takes in a string argument , which is the name of a person e.g. Bob.
I would like to know if it is possible to set the name as 'Bob' instead of Bob, at the moment i have:
CREATE PROCEDURE myProc
@myname nvarchar(20)
DECLARE @cmdSQL nvarchar(1000)
SET @cmdSQL = 'SELECT col1, col2, col3,
(SELECT col4 WHERE name = ' + @myname + ')....etc
EXECUTE(@cmdSQL)
at the moment I am getting the subquery as
(SELECT col4 WHERE name = Bob) but I actually want
(SELECT col4 WHERE name = 'Bob')
How do i insert the '' ?
Thanks in advance,
MrPeds