sqlserver 常用脚本
序号产生方式
方式1:row_number
select top 100 row_number() over (order by name) rowNumber from sys.objects
方式2:Identity
select top 100 Identity(int ,1,1) as n into #num from sys.columns
select * from #num
方式3:with as
with nums as(
select 1 as n
union all
select n+1 from nums where n<100
)
select * from nums
常用系统表
sys.objects, sys.columns,sys.types
常用系统函数
DB_ID('数据库名'), object_Id('表名')