Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
andrej351
Starting Member
6 Posts |
Posted - 2009-04-28 : 00:34:24
|
Hey everyone, I'm having an issue trying to bulk export some data out of a SQL Server 2000 database to a text file, then import it into a SQL Server 2005 database.My problem is i have a number of unique identifier columns which are all being exported WITHOUT the 4 dashes ie. 39A6EE1CE8CC4CA58B026969B9E45DB0 instead of 39A6EE1C-E8CC-4CA5-8B02-6969B9E45DB0. As a result they won't import straight into a uniqueidentifier column in my 2005 DB.If i manually put in the 4 dashes IT IMPORTS FINE.Does anyone have any idea why my export would be ommitting the dashes??Any idea how i could import uniqueidentifiers that are valid aside from having no dashes in them??More Details....My export is a cmd line bcp out that looks like this: bcp table out file -c -T -S serverMy import is a T-SQL script that looks like this:BULK INSERT db.dbo.table FROM 'C:\datafile.dat'WITH (DATAFILETYPE = 'char',KEEPIDENTITY,TABLOCK ) |
|
andrej351
Starting Member
6 Posts |
Posted - 2009-04-29 : 19:00:21
|
Hey,It turns out that the SQL 2000 database is storing the unique identifiers as varchars without the dashes, hence why they're being exported that way. The 2000 DB is our clients internal DB and therefore i had limited access to it and couldnt simply check the data type. Im guessing they've done this because of the current front end application to this database.So my solution is to import the IDs into char(32) columns, allowing me to set up any required PKs and FKs needed.Alternatively, i could've chained together a bunch of SUBSTRING function calls to manually insert the dashes as they are always in the same place. This could've bin nested inside a 'bcp substringSelectQuery queryout filename' bulk export.Case closed. |
|
|
|
|
|