日期:2014-05-18  浏览次数:20452 次

SQL2000 参数太长了
Declare @Command Varchar(2000) 
SET @PN80=''''+@PN80+''''
SET @PN80=replace(@PN80,',',''',''')
SET @Command='SELECT Customer,PN80,PN AS PN52,Dosage as Usage,Flow,Line,Hours,OutPutQty FROM HOURSSMT WHERE PN80 IN ('+@PN80+')'
EXEC(@Command)

这个@PN80有时候会非常的长,也就是字符串很长,这条SQL语句就报错了,不知道有什么解决办法呢,

------解决方案--------------------
Declare @Command Varchar(8000) SET @PN80=''''+@PN80+''''
SET @PN80=replace(@PN80,',',''',''')
SET @Command='SELECT Customer,PN80,PN AS PN52,Dosage as Usage,Flow,Line,Hours,OutPutQty FROM HOURSSMT WHERE PN80 IN ('+@PN80+')'
EXEC(@Command)


------解决方案--------------------

MSSQL2000不能那么写,的分开
@PN80 VARCHAR(MAX)
set @PN80=''
2008当中可以你那么写
探讨

引用:
给他设为varchar(max)试试,不够的话就换类型


引用:
Declare @Command Varchar(2000)
SET @PN80=''''+@PN80+''''
SET @PN80=replace(@PN80,',',''',''')
SET @Command='SELECT Cu……