Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import to varchar fields - ok? 1

Status
Not open for further replies.

pandatime

Programmer
Jan 29, 2010
92
AU
Hi,

When I do an import, I often just import to varchar fields, even if there is numeric or date fields in the file. Sometimes I can't tell what type of data is in a file necessarily so to me it seems safest to just import to varchar, as it seems to preserve the data without making any weird changes. Then I can change the column types later.

Is this an ok practice?

Thanks
 
I think it's perfectly ok to do this. Most people call it a "staging" table. The ONLY time I would worry about a staging table is if the data file is extremely large.... more than a gigabyte. With a staging table, you end up using more storage space and your log file can grow.

Basically, as long as you can tolerate the extra time and size, this is a perfectly acceptable practice.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
I hope so as I do the same thing on occasion. Mainly as an intermediate step.

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Ok, thanks... I just wanted to verify that varchar is a "safe" datatype... that it won't do anything strange to the data... seems so

(yes, this is a staging table)
 
The only time you might have a problem is if you have unicode data. Converting from unicode to varchar can cause some weird things to happen. To be completely safe, you could use nvarchar instead.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
The import tool converts to nvarchar automatically I noticed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top