简体   繁体   中英

Inserting T-SQL query text into SQL Server table

Can anyone help me to get this work.

[HOD_DESC] LIKE '%r%' is a formatted T-SQL query and I want insert into a table.

EXEC sp_s_saveReportSearch 'x= r ', '[HOD_DESC] LIKE '%r%''

Just escape the quotes by doubling them:

EXEC sp_s_saveReportSearch 'x= r ','[HOD_DESC] LIKE ''%r%'''

I really hope there's a good reason why you're doing this, however.

Double the quotes around quoted part of your SQL string:

EXEC sp_s_saveReportSearch 'x= r ','[HOD_DESC] LIKE ''%r%'''

In the column, inserted value will be [HOD_DESC] LIKE '%r%'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM