Loop through the tables and check if the datatype is appropriate to the data stored

  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • 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

    Jayanth Kurup[/url]

  • 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