Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Exec Statement Syntax

Author  Topic 

bclick
Starting Member

3 Posts

Posted - 2007-05-09 : 10:33:50
Having trouble getting correct syntax for Exec statement in a stored procedure. I have tried various combinations of quotes around the variables @fname & @lname with no success. They are all omitted here. Thanks for suggestions!


ALTER PROCEDURE [dbo].[spCompareOutput]
@tblSubordinate varchar(32),
@fname varchar(30),
@lname varchar(30)

AS
BEGIN
DECLARE @1sql varchar(1000)

SET @1sql = ' DELETE FROM '+ @tblSubordinate +
' WHERE firstname = ' + @fname + ' AND lastname = ' + @lname

EXEC (@1sql)
END

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-09 : 10:36:19
[code]SET @1sql = ' DELETE FROM '+ @tblSubordinate +
' WHERE firstname = ''' + @fname + ''' AND lastname = ''' + @lname + '''' [/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

bclick
Starting Member

3 Posts

Posted - 2007-05-09 : 10:45:02
Many Thanks to the Flowing Fount of Yak Knowledge!
Go to Top of Page
   

- Advertisement -