问一简单问题 select @s=@s+列一 from table where 公司代码 charindex(公司代码,','+@c+',')>0 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select @s=@s+列一 from table where charindex(公司代码,','+@c+',')>0 select @s=@s+列一 from table where 公司代码 in (@c)--------------改成select @s=@s+' 列一 from table where 公司代码 in ('+@c+')' 一直写错~~sorryselect @s=@s+列一 from table where charindex(','+公司代码+',',','+@c+',')>0 上面不對select @s=@s+列一 from table where 公司代码 in @c select @s=@s+列一 from table where 公司代码 in @c___________________________________________________这个好像还不行? try:------------------------------------------------------------------declare @v nvarchar(8000)declare @s nvarchar(8000)declare @c nvarchar(100)select @c='1,2,3'set @v = 'set @s = '''' select @s=@s+列一 from table where 公司代码 in ('+@c+')'exec sp_executesql @v,N'@s nvarchar(8000) out',@s outprint @s 插入自动生成的值 修改的SQL语句 请问如何获取Sql server表中列的默认值的数值 邹健 大哥有没在。。ANGET 的问题~~ 在线等 .. 将原有表转为分区表,如何保证原有表结构主键索引的唯一性 求一条SQL语句 虚拟光驱下载地址。。 本地数据库的技术参数问题 SQL转换排序字段来调整顺序 请问广义笛卡尔积和笛卡尔积到底有什么区别? 这个存储过程的变量应该设置成什么类型? 请教一条SQL__________________________请各大侠看看?
--------------改成
select @s=@s+' 列一 from table where 公司代码 in ('+@c+')'
select @s=@s+列一 from table where charindex(','+公司代码+',',','+@c+',')>0
select @s=@s+列一 from table where 公司代码 in @c
___________________________________________________这个好像还不行?
------------------------------------------------------------------
declare @v nvarchar(8000)
declare @s nvarchar(8000)
declare @c nvarchar(100)
select @c='1,2,3'
set @v = 'set @s = ''''
select @s=@s+列一 from table where 公司代码 in ('+@c+')'
exec sp_executesql @v,N'@s nvarchar(8000) out',@s out
print @s