SELECT Table_Name
FROM INFORMATION_SCHEMA.TABLES
WHILE (1=1)
BEGIN
EXEC 'drop view ' + Table_Name
END
or
DECLARE my_cursor CURSOR FOR
SELECT Table_Name
FROM INFORMATION_SCHEMA.TABLES
OPEN my_cursor
WHILE 1 = 1
BEGIN
FETCH my_cursor INTO @vname
IF @@fetch_status != 0 BREAK
EXEC('drop view ' + @vname)
END
CLOSE my_cursor;
The examples more or less describe what I'm doing, but that's not the question. The question is: When should I be trying to use an explicitly defined cursor, as in the second example, and what are the conditions where the first example would work?
Asked by david
(115 rep)
Dec 6, 2019, 03:39 AM
Last activity: Dec 6, 2019, 01:13 PM
Last activity: Dec 6, 2019, 01:13 PM