1、删除所有表
select 'drop table '+name+';' from sys.tables
where name like 'DataSyncV1DelaySample%'
or name like 'DataSyncV2DelaySample%'
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