Return to Snippet

Revision: 1978
at March 27, 2007 19:29 by rengber


Updated Code
SELECT 'public const string COLUMN_' + UPPER(col.TABLE_NAME) + '_' + UPPER(col.COLUMN_NAME) + ' = "' + col.COLUMN_NAME + '";' As [Name] 
FROM 		INFORMATION_SCHEMA.COLUMNS col
INNER JOIN 	INFORMATION_SCHEMA.TABLES tab ON tab.TABLE_NAME = col.TABLE_NAME 
WHERE 		tab.TABLE_TYPE = 'BASE TABLE'
AND			tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')

UNION

SELECT 		'public const string TABLE_' + UPPER(tab.TABLE_NAME) + ' = "' + tab.TABLE_NAME + '";' As sName 
FROM 		INFORMATION_SCHEMA.TABLES tab
WHERE 		tab.TABLE_TYPE = 'BASE TABLE'
AND			tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')
ORDER BY 	[Name] ASC

Revision: 1977
at December 7, 2006 14:58 by rengber


Initial Code
SELECT 		'public const string COLUMN_' + UPPER(col.TABLE_NAME) + '_' + UPPER(col.COLUMN_NAME) + ' = "' + col.COLUMN_NAME + '";' As [Name] 
FROM 		INFORMATION_SCHEMA.COLUMNS col
INNER JOIN 	INFORMATION_SCHEMA.TABLES tab ON tab.TABLE_NAME = col.TABLE_NAME 
WHERE 		tab.TABLE_TYPE = 'BASE TABLE'
AND			tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')

UNION

SELECT 		'public const string TABLE_' + UPPER(tab.TABLE_NAME) + ' = "' + tab.TABLE_NAME + '";' As sName 
FROM 		INFORMATION_SCHEMA.TABLES tab
WHERE 		tab.TABLE_TYPE = 'BASE TABLE'
AND			tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')
ORDER BY 	[Name] ASC

Initial URL

                                

Initial Description

                                

Initial Title
SQL Stored Proc to Generate a list of C# constants representing data field names.

Initial Tags
sql

Initial Language
C#