hello frnds i need to pass a table name as parameter to stored procedure
CREATE PROCEDURE six @tablename nvarchar
AS
SELECT * FROM + @tablename
Go
exec six Entry_sixsigma_mag
it gives error like
Msg 102, Level 15, State 1, Procedure six, Line 3 Incorrect syntax near '+'. Msg 208, Level 16, State 1, Procedure six, Line 3 Invalid object name '@sixsigma'.
Try something like
CREATE PROCEDURE six @tablename nvarchar(100)
AS
EXEC('SELECT * FROM ' + @tablename)
Go
exec six Entry_sixsigma_mag
Have a look at EXECUTE (Transact-SQL)
But you should also have a look at
before using this blindly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.