Tuesday, 30 December 2014

Check Table fields size and Data_types in sql server 2008r2 Columns Wise


--//Sql Queries

select DATA_TYPE,
 SUM(
 case
when DATA_TYPE='float' then 8
when DATA_TYPE='int'  then 8
when DATA_TYPE='datetime'  then 8
when DATA_TYPE='real'  then 4
when DATA_TYPE='decimal'  then 8
when DATA_TYPE='bigint'  then 8
when DATA_TYPE='smallint'  then 8
when DATA_TYPE='tinyint'  then 8
when DATA_TYPE='char'  then CHARACTER_MAXIMUM_LENGTH*1
when DATA_TYPE='bit'  then 1
when DATA_TYPE='nchar'  then CHARACTER_MAXIMUM_LENGTH*2
when DATA_TYPE='varchar'  then CHARACTER_MAXIMUM_LENGTH*2
else CHARACTER_MAXIMUM_LENGTH*2 end )as [Data_Type_Sizes],
count (DATA_TYPE)as [No Of Data_Types]
 from INFORMATION_SCHEMA.COLUMNS  where TABLE_NAME='Table Name'

 group by DATA_TYPE

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...