Finding datatype

  • I inheritated a table of ~2 million records, all in nvarchar(255) format (I don't know why)

    I'd prefer them to be in proper format, though a quick glance fails to show me each columns ideal format.

    Is there anyway I can run a query on each column to see if every row would fit into a certain data type?

    I can then create a new table and dump this table into that.

    Thanks!

  • If it were me I would make my best guess as to the proper type and do a trial insert into a table. To keep things simple and low overhead you could try it one column at a time. You may have to do some conversions on the existing data during the insert, but the only way to know for sure is to try it.

    The probability of survival is inversely proportional to the angle of arrival.

  • "Guestimate" is the keyword.

    You could start with determining each columns max data length (/2 for the number of chars)

    Then create your trial table and try the import.

    Keep in mind to check with the apps ... what is their need ?

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply