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


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. SELECT 'public const string COLUMN_' + UPPER(col.TABLE_NAME) + '_' + UPPER(col.COLUMN_NAME) + ' = "' + col.COLUMN_NAME + '";' As [Name]
  2. FROM INFORMATION_SCHEMA.COLUMNS col
  3. INNER JOIN INFORMATION_SCHEMA.TABLES tab ON tab.TABLE_NAME = col.TABLE_NAME
  4. WHERE tab.TABLE_TYPE = 'BASE TABLE'
  5. AND tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')
  6.  
  7. UNION
  8.  
  9. SELECT 'public const string TABLE_' + UPPER(tab.TABLE_NAME) + ' = "' + tab.TABLE_NAME + '";' As sName
  10. FROM INFORMATION_SCHEMA.TABLES tab
  11. WHERE tab.TABLE_TYPE = 'BASE TABLE'
  12. AND tab.TABLE_NAME NOT IN ('dtproperties', 'sysdiagrams')
  13. ORDER BY [Name] ASC

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.