Thursday, May 5, 2022

SQL script to delete all staging table data in D365FO

 declare cu cursor for SELECT [name] FROM SYSTABLEIDVIEW where [name] like '%Staging'

declare @table varchar(100)

declare @sql nvarchar(1000)

OPEN cu  

FETCH NEXT FROM cu INTO @table 

WHILE @@FETCH_STATUS = 0  

BEGIN  

    set @sql = N'delete from ' + @table

    PRINT @table

    EXEC sp_executesql @sql

    FETCH NEXT FROM cu INTO @table 

END   

CLOSE cu;  

DEALLOCATE cu;

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...