sql server 删除数据库所有表结构与数据与递归查询
select 'drop table '+name+';' from sys.tables where name like 'DataSyncV1DelaySample%'
or name like 'DataSyncV2DelaySample%'
删除所有表结构与表数据
递归函数
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。复制代码 ALTER FUNCTION [dbo].[RecursionSysLocation] ( -- Add the parameters for the function here
@ParentId nvarchar(36) ) RETURNS TABLE
AS
RETURN ( 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 )

更多精彩