question

mayankbhargava avatar image
mayankbhargava asked

sqlcmd error when running query through cmd file

Hi, I am using the below query for getting data to a variable in command file . sqlcmd -E -q "SELECT temp.b FROM (SELECT x.source.value('@key', 'VARCHAR(255)') AS A, x.source.value('.', 'VARCHAR(255)') AS B FROM (SELECT Cast(x AS XML) FROM OPENROWSET( BULK 'C:\axiom\warehouse\webroot\data_user\settings\settings.xml', single_blob) AS T(x)) AS T(x) CROSS apply x.nodes('settings/setting') AS X(source)) AS temp WHERE temp.a = 'source_ip_address'" THe error I am getting is : Msg 1934, Level 16, State 1, Server GDWHREPT01, Line 1 SELECT failed because the following SET options have incorrect settings: 'QUOTED _IDENTIFIER'. Verify that SET options are correct for use with indexed views and /or indexes on computed columns and/or filtered indexes and/or query notificatio ns and/or XML data type methods and/or spatial index operations. Can some one please guide?
querysqlcmd
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
raadee avatar image
raadee answered
Add -I to SQLCMD to set the SET QUOTED_IDENTIFIER connection option to ON. By default, it is set to OFF. [sqlcmd Utility link][1] [1]: http://technet.microsoft.com/en-us/library/ms162773.aspx
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.