如果变量@id是int,那么
declare @id int
select * from yourtable where [group] like '%'+cast(@id as varchar)+'%'如果是char
declare @id char(1)
select * from yourtable where [group] like '%'+@id +'%'
declare @id int
select * from yourtable where [group] like '%'+cast(@id as varchar)+'%'如果是char
declare @id char(1)
select * from yourtable where [group] like '%'+@id +'%'
谢谢! 如果 “id”是作为一个查询条件的话,该如何?
比如就 “select * from tablename where ?”
”?“里的内容怎么填? 谢谢!
select @id='[group] like ''%4%'' and name=''c'''
select @string='select * from tablename where '+@id
--select @string
exec(@string)