Hi Experts,
I want to pass the table name dynamically to the following query and get it created:
DECLARE @SQL varchar(MAX);
DECLARE @TableName varchar(255);
SET @SQL = '"CREATE TABLE + @TableName+ (
[ID] [int] IDENTITY(1,1) NOT NULL,
[AgencyName] [nvarchar](255) NULL,
[ServiceID] [nvarchar](255) NULL,
) ON [PRIMARY]"';
execute (@SQL);
Open in new window
And usually, I got an error with the single quotation. So, could you please tell me what the correct way to get it working?
Thanks a lot in advance.
Harreni