有个存储中有个输入参数 设置为 varchar(max) 但是传入{ParentID in(984,985,986,987,988,989,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1006,1007,1008,1009,1010,1011,1012,1014,1015,1016,1017,1018,1020,1021,1022,1023,1024,1105,1252,1273,1274,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1468,1472,1478,1497,1504,1659,1025,1027,1178,1187,1188,1238,1242,1251,1589,1594,1380,1403,1404,1425,1426,1458,1477,1549,1550,1577,1501,1502,1503,1510,1518,1554,1555,1557,1558,1568,1569,1570,1571,1572,1573,1574,1575,1585,1586,1587,1588) and PageTitle like '%角色%' and ((UserType='Lab' and ID not in(1,7))) order by OrderIndex} 这个参数时 会报错,请问有解决方法吗?这个是因为过长报错吗?反正我把参数改短就能正常执行。。。。
具体的错误信息是什么啊????
127 附近有语法错误, as 附近有语法错误。但是当这个参数变短后就没错误了
换成nvarchar(max) 或许能更长一点,如果你还有更长的字符串 那八成还得报错
就上边那参数 换成nvarchar(max) 也会报错,消息 102,级别 15,状态 1,第 1 行
'1' 附近有语法错误。
@差生: 那就是说明还不够长呗 。。 你可以把这些数字转换成 byte[] 传递,然后再存储过程中解析出来
1 Create PROCEDURE XXX 2 -- Add the parameters for the stored procedure here 3 @id varbinary(4096) 4 5 AS 6 BEGIN 7 -- SET NOCOUNT ON added to prevent extra result sets from 8 -- interfering with SELECT statements. 9 SET NOCOUNT ON; 10 11 -- Insert statements for procedure here 12 declare @vbIDTmp binary(4), @count int, @j int, @ID int 13 Declare @tbList as Table(id int identity,tmpID int) 14 15 set @count = datalength(@id) 16 if @count = 0 17 begin 18 return; 19 end 20 if @count % 4 <> 0 21 begin 22 return; 23 end 24 set @j = @count - 4 + 1 25 26 while(@j >= 1) 27 begin 28 select @ID = cast(substring(@id,@j,4) as int),@j = @j - 4 29 insert Into @tbList(tmpID) Values(@ID) 30 end 31 32 33 END
这点长度,还达不到数据库的极限。你看下具体的错误信息!