Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
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: 591 | Views in the last 30 days: 6
 
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
format    
information_schema    
utility    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones