且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 EXEC 的结果创建新表

更新时间:2023-02-06 11:26:38

根据评论,尤其是来自 @Larnu 的评论

Per the comments, particularly from @Larnu

DECLARE @sqlcode VARCHAR(MAX)
SET @sqlcode = 'sqlcode'

DROP TABLE IF EXISTS [jerry].[dbo].[purchases]
truncate table [jerry].[dbo].[purchases]
insert into [jerry].[dbo].[purchases]
exec ( @sqlcode ) at OLAP

几乎正确,但需要切换到

Was nearly correct, but needed to be switched to

DECLARE @sqlcode VARCHAR(MAX)
SET @sqlcode = 'sqlcode'

truncate table [jerry].[dbo].[purchases]
insert into [jerry].[dbo].[purchases]
exec ( @sqlcode ) at OLAP

因为我无法删除一个表,然后在不重新创建它的情况下对其执行任何操作.

Since I could not drop a table and then perform any operation on it without recreating it.