请问以下SQL语句为何不正确?

[复制链接]
查看11 | 回复2 | 2009-2-8 13:46:28 | 显示全部楼层 |阅读模式
declare @id int
declare @str nvarchar(5)
set @id=1
set @str=N'模块'
while @id9时,还是会出错。不妨改大点...
回复

使用道具 举报

千问 | 2009-2-8 13:46:28 | 显示全部楼层
insert into testmodule(modulename) values(@str+@id) 这句改为exec('insert into testmodule(modulename) values('+@str+cast(@id as nvarchar(2)+')')这样就可以了。祝你好运!...
回复

使用道具 举报

千问 | 2009-2-8 13:46:28 | 显示全部楼层
set @str=N'模块' select @str = rtrim(convert(char(10),N))+'模块'...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行