Wednesday, 17 December 2014

Get Table columns names, schema, datatype and more using sql query





select *
 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Table Name here'



//For Particular


select '['+COLUMN_NAME+']',DATA_TYPE,

case when CONVERT(varchar, CHARACTER_MAXIMUM_LENGTH)>then CHARACTER_MAXIMUM_LENGTH else '' end as mm,case when IS_NULLABLE='Yes' then 'NULL,' else 'NOT NULL,' end as tt

 from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME=' Table Name here'

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...