A Journey 2 Eternity

Retrieving the table column details

Posted on: November 16, 2011

The following query retrieving the table column details.

SELECT COLUMN_NAME [Field],DATA_TYPE + '(' + ISNULL(CONVERT(NVARCHAR,CHARACTER_MAXIMUM_LENGTH),'') + ')' + '    ' + CASE WHEN IS_NULLABLE = 'NO' THEN 'NOT ' ELSE '' END + 'NULL' [Type] 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = 'account' 
ORDER BY ORDINAL_POSITION ASC
Advertisements
Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

November 2011
M T W T F S S
« Jun   Dec »
 123456
78910111213
14151617181920
21222324252627
282930  

Blog Stats

  • 26,968 hits
%d bloggers like this: