Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Generate Column Metadata

By Steven Willis,

This procedure will print to the SSMS messages window a
formatted list of column names for tables, procedures, and
views that can be cut and pasted for creating other scripts 
and procedures. 
Options include adding brackets if that's your thing, pulling
actual sample data from the table/view specified, or you can
create your own custom query.
Format types are shown right below. At the very bottom I've
included examples of how to use the procedure. Below that I've
added scripts for creating a test table, test view, and a test
procedure. Run those once, then highlight all of the examples
(all at once if you want to) and you'll get the idea.
I'm sure I haven't covered every possible format someone 
might want nor will some of the options do anything on every
format type. Also, performance was not really an issue here
since it seems plenty fast enough for something that is just 
an ad hoc utility.
Please feel free to take this ball and run with
it. Just post to the forum any ideas or improvements so
everyone can benefit.
Regards
Steven Willis
19 January 2013

Total article views: 674 | Views in the last 30 days: 5
 
Related Articles
FORUM

date format in stored procedure

date format in stored procedure

FORUM

create Procedure within Procedure

create Procedure within Procedure

FORUM

Need help on HTML formatted email from Stored Procedure

Stored Procedure email like HTML format

FORUM

Create procedure permission in schema

Create procedure permission in schema

FORUM

To Create PDF from SQL stored procedure

To Create PDF from SQL stored procedure

Tags
formatting    
information_schema    
utility    
 
Contribute