Skip to main content
Added profiler output
Source Link

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

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?

The only workaround I kind of found is to wrap the table name with the single quotes, which is a bit annoying.

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

Added the tag of the DBMS of relevance; modified formatting; made some rewordings.
Source Link
MDCCL
  • 8.5k
  • 3
  • 31
  • 62

Unable to pass scema.object to the query shortcut in management studioSSMS 2016

I am having a query shortcut that is generating create table sqlin SQL Server Management Studio 2016. This works fine for when I am not trying to select schema.table. Onceschema.table, but once I am trying to select such object I am getting error Incorrect syntax near '.''.'.

myMy query shortcut looks like exec sp_executesql 'huge sql oneliner', N'@table_name SYSNAME', @table_name =:

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?

The only workaround I kindakind of found itis to wrap the table name with the single quotes, which is a bit annoying.

Unable to pass scema.object to the query shortcut in management studio 2016

I am having a query shortcut that is generating create table sql. This works fine for when I am not trying to select schema.table. 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?

The only workaround I kinda found it to wrap table with the single quotes which is a bit annoying.

Unable to pass scema.object to the query shortcut in SSMS 2016

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?

The only workaround I kind of found is to wrap the table name with the single quotes, which is a bit annoying.

added workaround
Source Link

I am having a query shortcut that is generating create table sql. This works fine for when I am not trying to select schema.table. 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?

The only workaround I kinda found it to wrap table with the single quotes which is a bit annoying.

I am having a query shortcut that is generating create table sql. This works fine for when I am not trying to select schema.table. 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?

I am having a query shortcut that is generating create table sql. This works fine for when I am not trying to select schema.table. 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?

The only workaround I kinda found it to wrap table with the single quotes which is a bit annoying.

Source Link
Loading