摘要:
declare@sqlstrvarchar(3000) set@sqlstr='declare@subsqlstrvarchar(1000);' set@sqlstr=@sqlstr+'set@subsqlstr=''select*fromtblproducts'';' set@sqlstr=@sqlstr+'execute(@subsqlstr)' execute(@sqlstr)在上面的代码中,@SQL变量中定义的是一组SQL语句,在这组SQL语句中,又定义了一个@SUBSQL变量,在其中存放了SELECT语句 阅读全文
摘要:
select ServiceStaff, * from Project_Hdr where Id=12原查询结果 'XM2053,XM205'执行下面语句select code=substring(a.ServiceStaff,b.number,charindex(',',a.ServiceStaff+',',b.number+1)-b.number),* from Project_Hdr a, master..spt_values b where b.type='p' and b.number<=len(a.Service 阅读全文