DECLARE @SQL VARCHAR(8000), @SALETABEL VARCHAR(100)SET @SQL='ALTER VIEW DBO.SCOST AS 'DECLARE SALELIST CURSOR SCROLL FOR SELECT 'SELECT * FROM SALECOST UNION ALL ' TABLENAME UNION ALL SELECT 'SELECT * FROM '+LTRIM(RTRIM(NAME))+' UNION ALL ' FROM SYSOBJECTS WHERE NAME LIKE 'SALECOST201%' AND XTYPE='U'OPEN SALELISTFETCH NEXT FROM SALELIST INTO @SALETABELWHILE @@FETCH_STATUS=0BEGIN SET @SQL=@SQL+@SALETABEL FETCH NEXT FROM SALELIST INTO @SALETABELENDCLOSE SALELISTDEALLOCATE SALELISTSET @SQL=SUBSTRING(@SQL,1,LEN(@SQL)-10)EXEC(@SQL)