I am attempting to create a stored procedure where a table name is passed as a parameter, as well as updating contents of the table. Here is my code I have so far.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE TableSelect
@TableName varchar(100)
AS
BEGIN
SET NOCOUNT ON;
Declare @String varchar(100)
SELECT @String = 'Update '
SELECT @String = @String + @TableName
SELECT @String = @String + 'Set Internet = 1'
EXEC (@String)
END
GO
When I attempt to execute by this command:
EXEC TableSelect 'Waterford';
I get the error:
Msg 102, Lvevl 15, State 1, Line 1
Incorrect syntax near 'Internet'.
Any help would be great. FYI, the column Internet, is just a bit so 0/1 or False/True. Thanks
Where the entered @TableName is displayed when executed.
– user3268054 Jul 01 '15 at 18:54