tommym121
asked on
SQL - error in using a parameter in SQL Stored procedure
CREATE PROCEDURE FindDuplicateRecordIn
-- Add the parameters for the stored procedure here
@table nvarchar(256) = ' ',
@column nvarchar(256) = ' '
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT * FROM @table GROUP BY @column
END
When I compile, I have the following error:
Msg 137, Level 15, State 2, Procedure FindDuplicateRecordIn, Line 16
Must declare the variable '@table'.
GO
I am not sure why, @table is pass down as an argument from the store procedure. I change the @table to @table1. Same error
-- Add the parameters for the stored procedure here
@table nvarchar(256) = ' ',
@column nvarchar(256) = ' '
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT * FROM @table GROUP BY @column
END
When I compile, I have the following error:
Msg 137, Level 15, State 2, Procedure FindDuplicateRecordIn, Line 16
Must declare the variable '@table'.
GO
I am not sure why, @table is pass down as an argument from the store procedure. I change the @table to @table1. Same error
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Did you try my post? The accepted post and mine are same except I used EXEC. Anyway lets move on.
Open in new window