EXEC动态填充表赋空值
[code=SQL][/code]
alter procedure tiaoshi
@tablename nvarchar(80),
@rowindex nvarchar(8)
as
declare @sql varchar(8000)
set @sql='declare @order table(sequence int, uut nvarchar(8) null) insert into @order select sequence from'+@tablename+'insert into @order values(' +@roeindex+ ',null) select * from @order order by sequence'
exec(@sql)
return
报错,显示输入参数不符合定义,我希望达到的目的是列uut输入为空值,尝试过将列的默认值设置为空,插入一个参数,结果也是报错,显示参数个数不对,希望高手指点
[解决办法]
--alter procedure tiaoshi declare @tablename nvarchar(80) declare @rowindex nvarchar(8)--as declare @sql varchar(8000) set @sql='declare @order table(sequence int, uut nvarchar(8) null) insert into @order --这个地方添加上列名sequence insert into @order select sequence from'+@tablename+' insert into @order values(' +@rowindex+ ',null) --允许null的列,可以不写 values(' +@rowindex+ ') select * from @order order by sequence' print @sql --拼接后的字符串,LZ最好print出来看看 --exec(@sql) --return