Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi Forumians,I have to execute the below queryinsert into queryvalues('to find ipaddress','exec master..xp_cmdshell 'ipconfig'','http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=148251',getdate())here i have ' character in between the 2 nd attribute. how to store this value exec master..xp_cmdshell 'ipconfig' in the query table.i am getting d below errorServer: Msg 170, Level 15, State 1, Line 4Line 4: Incorrect syntax near 'ipconfig'.Note i have to enclose ipconfig word in single quote.
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-06-03 : 08:44:44
You can escape a single quote with another single quote. So
insert into queryvalues('to find ipaddress','exec master..xp_cmdshell ''ipconfig''','http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=148251',getdate())
Lamprey
Master Smack Fu Yak Hacker
4614 Posts
Posted - 2011-06-03 : 11:28:15
Another alternative is to use the CHAR function to replace single quotes. For example: