用动态SQL 实现带参数的 identity函数功能(可以实现给列前加上序号的功能)
declare @a int,@s varchar(100)
set @a = 100
set @s = 'Select top 10 identity(int,'+cast(@a as char(3))+',2) as XH into ##t from sysobjects'
--print @s
exec(@s)
Select * from ##t
declare @a int,@s varchar(100)
set @a = 100
set @s = 'Select top 10 identity(int,'+cast(@a as char(3))+',2) as XH into ##t from sysobjects'
--print @s
exec(@s)
Select * from ##t
本文介绍如何使用动态SQL来实现带有参数的identity函数功能,该方法可以在表中的特定列前自动添加序号,通过设置不同的参数可以改变序号的起始值。
2734

被折叠的 条评论
为什么被折叠?



