February 22, 2012 at 12:40 am
Is there a way to loop through all tables in a database and check if the datatypes are appropriate to the stored data.
thanks
Alberto
February 22, 2012 at 12:56 am
How would you know/define whether the datatype is appropriate? Looping through the tables is easy.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
February 22, 2012 at 1:25 am
Example
INT column type, maximum value is 120, the type TINYINT is enough;
varchar (255) column type, maximum data length 13 characters, othe type varchar (13) is enough.
Thanks
February 22, 2012 at 1:28 am
That's not a good idea, a table like employee id could stop at 150 today but might need to be able to store 1231321 at a later date.
choosing int over varchar is easy determining the precision is not, it requires an understanding of the data and the context of the value and any suitable buffer for accommodate future changes
February 22, 2012 at 1:31 am
I know I will not change automatically sorts, I just want to be aware and decide whether to change the type.
thanks
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply