How to use like sentence in sp_executesql
Today, I will talk to you about how to use like in sp_executesql. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
Declare @ LikeSql nvarchar (32);-- define a like variable. If it is a stored procedure, the parameter set @ LikeSql = 'someword%';-- of the stored procedure can assign the LikeSql variable to'% xxxxxxxxxxxx%' declare @ SelectSql nvarchar (128)-- define the Sql statement and start spelling Sql set @ SelectSql = 'select * from Table where [Column] like @ LikePar' -use @ LikePar variable to parameterize exec sp_executesql @ SelectSql, N'@LikePar as varchar (32)', @ LikePar = @ LikeSql;-- to execute using sp_executesql
After reading the above, do you have any further understanding of how to use like in sp_executesql? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.