--TSQL SNIPPET FOR LISTING TABLE COLUMNS AS LIST FOR SELECT , UPDATE INSERT STATEMENTS
set nocount off;
--SEARCH FOR A TABLE WHICH HAS "TableName" IN ITS NAME
select name AS 'TABLE_NAME'from sys.tables where name like '%TableNa%'
--PRINT THE COLUMNS OF THIS TABLE
DECLARE @ColName varchar(100)
DECLARE @cursorColNames CURSOR
SET @cursorColNames = CURSOR FOR
select column_name from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='TableName'
OPEN @cursorColNames
FETCH NEXT
FROM @cursorColNames INTO @ColName
WHILE @@FETCH_STATUS = 0
BEGIN
--set nocount off;
print '[' + @ColName + '],'
FETCH NEXT
FROM @cursorColNames INTO @ColName
END
CLOSE @cursorColNames
select @@error