I Have created a procedure which has code like this:
Create PROCEDURE Sample( @ID INT )
AS
BEGIN
DECLARE @SQL NVARCHAR(max)
DECLARE @SchemaName SYSNAME
DECLARE @TableName SYSNAME
DECLARE @DatabaseName SYSNAME
SELECT @SQL = 'Create Table ' + @DatabaseName + '.'
+ @SchemaName + '.' + @TableName
+ '_temp' + '('
SELECT @SQL = @SQL + 'ID int NOT NULL Primary Key, Name VarChar(10))'
I Always get error as :
Msg 102, Level 15, State 1, Line 77 Incorrect syntax near ','.
Can anyone help me on this?