Tuesday, 30 December 2014

Check Table fields size and Data_types in sql server 2008r2 Table Wise (All tables of selected database)

//sql query

select TABLE_NAME, 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 ttt  from INFORMATION_SCHEMA.COLUMNS
 where TABLE_NAME in (select TABLE_NAME  from INFORMATION_SCHEMA.TABLES where TABLE_TYPE='BASE TABLE')
  group by TABLE_NAME


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