I need to execute a bunch of SQL scripts that need to be executed in order as they are dependent upon each other. The workflow modifies some of the date values within each script. The scripts are stored locally(this is a requirement).
My plan was to feed each script into a dynamic input in a control container and connect the control containers to control the sequence order. These scripts are fully self-contained and do all the DROPS, CREATES, and WRITES.
The tables are correctly read from/written to, but I am getting the error "No columns returned". Based on some google-fu this because there are no results being returned; which makes sense because this is true. I've tried several methods of adding an additional statement on the end to get some "results", but that hasn't worked.
SQL attached below. Anyone have any other ideas?
-- Step 1: Clear all data from the destination table.
-- TRUNCATE TABLE is used for performance as it's a minimally logged operation.
TRUNCATE TABLE [Sandbox].[dbo].[WRITE_TEST_2];
-- Step 2: Copy all data from the source table to the destination table.
-- It assumes the column structure of both tables is identical.
INSERT INTO [Sandbox].[dbo].[WRITE_TEST_2]
SELECT *
FROM [Sandbox].[dbo].[WRITE_TEST_1]
WHERE BegindDate = '1901-01-01' AND EndDate = '1901-12-31';
-- Step 3: Return a result set to avoid the "no columns returned" error.
-- @@ROWCOUNT returns the number of rows affected by the last statement (the INSERT).
-- This provides a meaningful result and confirms the operation's success.
SELECT @@ROWCOUNT AS RowsCopied;