DECLARE @SQL VARCHAR(MAX)
DECLARE test_cursor CURSOR
SCROLL FOR
SELECT PFDB_No from dbo.PFDBInfoTable
OPEN test_cursor
DECLARE @PFDBNo nchar(11)
FETCH NEXT FROM test_cursor INTO @PFDBNo
WHILE
@@FETCH_STATUS=0
BEGIN
PRINT @PFDBNo
SET @SQL=‘SELECT * FROM ‘[email protected]+‘.dbo.BarNoTable‘ EXEC (@SQL)
FETCH NEXT FROM test_cursor INTO @PFDBNo END
CLOSE test_cursor
DEALLOCATE test_cursor
时间: 2024-10-12 20:02:06