Y
yjlucky
Unregistered / Unconfirmed
GUEST, unregistred user!
近日将原先的access程序移植到sqlserver 2000发现如下sql语句有问题。sql.Add('select top 10 * from messagelist');sql.Add('where msgtype=:msgtype1 and stcd=:stcd1');sql.Add('and id not in (SELECT top 10 id from messagelist where msgtype=:msgtype2 and stcd=:stcd2 order by id desc)');sql.Add('order by id desc');Parameters.ParamByName('msgtype1').Value := '通知';Parameters.ParamByName('stcd1').Value := '0';Parameters.ParamByName('msgtype2').Value := '通知';Parameters.ParamByName('stcd2').Value := '0';用sql事件查看器发现,运行的是如下语句exec sp_executesql N'select top 10 * from messagelistwhere msgtype=@P1 and stcd=@P2and id not in (SELECT top 10 id from messagelist where msgtype=@P3 and stcd=@P4 order by id desc)order by id desc', N'@P1 nvarchar(10),@P2 nvarchar(1),@P3 varchar(2),@P4 varchar(1)', N'通知', N'0', '通', '0''通知'少了一个'知',这是怎么回事呀? msgtype数据类型为nvarchar(10),stcd数据类型为nvarchar(1)