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)

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: 109 | Views in the last 30 days: 1
Related Articles

Updating varchar(max) column

Updating varchar(max) column


Aggregrating varchar columns

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


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

Altering column datatype to varchar(max)


Varchar column conversion

Converting a column with Data Type of Varchar to Datetime


Export VarChar(6500) column

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


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

Already a member? Jump in:

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