--select column_name from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Products'
--Declare the Table variable
DECLARE @TableNames TABLE
(
Number INT IDENTITY(1,1), --Auto incrementing Identity column
TableName VARCHAR(300) --The string value
)
--Decalre a variable to remember the position of the current delimiter
DECLARE @CurrentDelimiterPositionVar INT
--Decalre a variable to remember the number of rows in the table
DECLARE @Count INT
DECLARE @SqlCode varchar(200)
--Populate the TABLE variable using some logic
INSERT INTO @TableNames SELECT name FROM sys.tables
--Initialize the looper variable
SET @CurrentDelimiterPositionVar = 1
--Determine the number of rows in the Table
SELECT @Count=max(Number) from @TableNames
--A variable to hold the currently selected value from the table
DECLARE @TableName varchar(300);
--Loop through until all row processing is done
WHILE @CurrentDelimiterPositionVar <= @Count
BEGIN
--Load current value from the Table
SELECT @TableName = TableName FROM @TableNames WHERE Number = @CurrentDelimiterPositionVar
--Process the current value
print 'EXEC [dbo].[procUtils_GenerateInsertProc] @TableName = N'''+ @TableName + ''''
--Increment loop counter
SET @CurrentDelimiterPositionVar = @CurrentDelimiterPositionVar + 1;
END
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!