1、删除所有表

select 'drop table '+name+';' from sys.tables where name like 'DataSyncV1DelaySample%' 
or name like 'DataSyncV2DelaySample%'

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

2、递归查询 使用关键字with as

 with temp ( [Id], [parentid]) as ( select Id, ParentId from SysLocation where ParentId = @ParentId
        union all
        select a.Id, a.ParentId from SysLocation a inner join temp on a.ParentId = temp.[Id] ) select s.Id, s.ParentId from SysLocation s where Id=@ParentId
    union all
    select * from temp

 

3、数字类型转为字符串

select convert(varchar(11),convert(decimal(11,0),mo)) as m  from test

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄