Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

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

Retrieve column attributes

By anonuser,

Given database, owner, table, and column names, this procedure returns one from among several column attributes such as type definition, defaults, and other types of constraints.  E.g., to retrieve the type definition of the 'pubs' database's 'author.address':

DECLARE @attrib VARCHAR (500)
      , @msg    VARCHAR (8000)

EXEC p_get_column_attribute 'TYPEDEF'
                          , 'authors'
                          , 'address'
                          , @msg    OUTPUT
                          , @attrib OUTPUT
                          , 'pubs', 'dbo'
PRINT @attrib

(Answer:  'VARCHAR (40)')

Total article views: 108 | Views in the last 30 days: 2
 
Related Articles
FORUM

Updating varchar(max) column

Updating varchar(max) column

SCRIPT

Aggregrating varchar columns

Concatenate columns grouping on Index column (approach for summing varchar columns by grouping on in...

FORUM

Altering column from varchar(2048) to varchar(max) performance

Altering column datatype to varchar(max)

FORUM

Varchar column conversion

Converting a column with Data Type of Varchar to Datetime

FORUM

Export VarChar(6500) column

Unable to export VarChar(6500) column to CSV / XLS

 
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