I want to get the output by returning in the course question against the values from the following SQL query question. I want to record this print. How can I do that? Thank you for your help.
SQL query:
SELECT
[NoMatchExplanation],
COUNT(*)
FROM
err.CustomerBank
GROUP BY
(NoMatchExplanation)
Cursor query:
DECLARE cr_Read CURSOR FOR
SELECT TABLE_SCHEMA + '.' + TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'err'
DECLARE @name NVARCHAR(100)
OPEN cr_Read
FETCH NEXT FROM cr_Read INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO etl.ErrorTable VALUES (@name)
FETCH NEXT FROM cr_Read INTO @name
END
CLOSE cr_Read
DEALLOCATE cr_Read