By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

Assigning value to @cmd gets error - Incorrect syntax near '/'.

P: 19
This works:

Expand|Select|Wrap|Line Numbers
  1. SELECT CData.value('(/fields/Genres)[1]', 'varchar(255)')FROM Categories WHERE ReqNum = 9281 
This does not:

Expand|Select|Wrap|Line Numbers
  1. DECLARE @cmd varchar (1000)
  2. SET @cmd = 'SELECT CData.value('(/fields/Genres)[1]', 'varchar(255)')FROM Categories WHERE ReqNum = 9281' 
I get this error: Incorrect syntax near '/'.

How do I resolve this error?
Feb 18 '14 #1

✓ answered by Rabbit

You need to escape your quotes.

Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,430
You need to escape your quotes.
Feb 18 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.