I was trying to create stored procedure for create table as below:
CREATE PROCEDURE tableCreation
AS
DECLARE @tableName NVARCHAR(30)
SET @tableName = 'Employee'
BEGIN
CREATE TABLE @tableName (
id INT NOT NULL
)
END
but when I execute the procedure, I get this error:
Msg 102, Level 15, State 1, Procedure tableCreation, Line 7
Incorrect syntax near '@tableName'.
What is the issue with above procedure or is there any other way to achieve above task?