首页 > 数据库技术 > 详细

sql server 删除所有表和递归查询、数字类型转为字符串

时间:2019-04-19 11:49:36      阅读:126      评论:0      收藏:0      [点我收藏+]

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

 

sql server 删除所有表和递归查询、数字类型转为字符串

原文:https://www.cnblogs.com/zoro-zero/p/10734651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!