I am having a query shortcut that is generating create table in SQL Server Management Studio 2016. This works fine when I am not trying to select schema.table
, but once I am trying to select such object I am getting error Incorrect syntax near '.'
.
My query shortcut looks like:
exec sp_executesql 'huge sql oneliner', N'@table_name SYSNAME', @table_name =
Any idea how I can pass objects like that to the query shortcut?
update 1:
The only workaround I kind of found is to wrap the table name with the single quotes, which is a bit annoying.
update 2:
I simplified my shortcut a bit for debugging purposes:
exec sp_executesql N'select @table_name;', N'@table_name varchar(max)', @table_name =
and when I ran it this is what I captured in the Profiler:
exec sp_executesql N'select @table_name;', N'@table_name varchar(max)', @table_name = dbo.Categories
which makes sense for the workaround I found earlier, but still would love to make it work without surrounding it in single quotes by myself