Exporting data to text file
thomask
Posts: 15
Hi there - I want to export my table data to a text file.
The thing is, I want to store data from certain core tables with my versioning control system and then load them into an empty database.
Moreover, I want the format to be in a text format in order to make it easy for my co-developers to detect conflicts and do merges on these text files.
I've had a look at the "bcp" utility but the file it is producing does not lend itself to an easy merge/conflict resolution.
I guess it would be ideal if I could do a "data compare" to a file folder similar to the way SQL Compare Pro can do a schema compare to a script folder
Does anyone know of a feature in SQL Data Compare or another tool (Red Gate or otherwise) which can do this?
Cheers,
Thomas
The thing is, I want to store data from certain core tables with my versioning control system and then load them into an empty database.
Moreover, I want the format to be in a text format in order to make it easy for my co-developers to detect conflicts and do merges on these text files.
I've had a look at the "bcp" utility but the file it is producing does not lend itself to an easy merge/conflict resolution.
I guess it would be ideal if I could do a "data compare" to a file folder similar to the way SQL Compare Pro can do a schema compare to a script folder
Does anyone know of a feature in SQL Data Compare or another tool (Red Gate or otherwise) which can do this?
Cheers,
Thomas
Comments
We are considering support some sort of text file representation of data that SQL Data Compare could read and write, but we haven't yet decided what is the best format for this. Having DML (INSERT statements) would make it consistent to what SQL Compare does, although having a simple csv file would make it easier to edit details directly in source control, and would provide a format that could be used for a BULK INSERT. I'm sure that other formats could also work.
What format would work best for you?
David Atkinson
Product Management
Red Gate Software
Product Manager
Redgate Software
The nice thing about INSERTs is that it would work more or less out of the box. With CSV you'd still need some other tool in order to insert it into the table.
Regards
Thomas
I'd be interested to know whether others would want this feature in SQL Data Compare, and if so, which format would work best.
Thanks,
David Atkinson
Product Manager
Red Gate Software
Product Manager
Redgate Software
For that purpose, I would say TEXT > INSERT/DML
but obviously when there's the need to INSERT, obviously having INSERT is nice - but I thought that's why Data Compare exists in the first place - you hit a button and it synchronizes data for you, without the need for INSERT statement
I forgot now, doesn't Data Compare generate a script like SQL Compare? which will be purely INSERT if you compare with empty database
DBA, MCITP
David Atkinson
Red Gate Software
Product Manager
Redgate Software
My ambition is to create a build/deploy procedure that given a tag in subversion will do the following:
1) Check-out all my files from SubVersion.
2) Build the application.
3) Create an empty database.
4) Use SQL Compare Pro to create all the tables, SP's, UDF's, etc in the empty database from the script files.
5) Run the data-scripts discuseed in this thread to insert "core" data.
I am very close to completing these steps, I am only missing a nice (easy) way of creating the data files for step 5.
Cheers,
Thomas
Would this work for you?
David Atkinson
Red Gate Software
Product Manager
Redgate Software
The reason I am searching for an easy tool to do the data file part is to "ease the pain of change" in the development team.
I am currently considering building a quick tool using the free filehelpers library (http://www.filehelpers.com/)
Cheers,
Thomas
This sounds interesting. Could you describe exactly what this tool would do?
David
Product Manager
Redgate Software
I tried to use Export Comparison Results (only inserts) to generate CSV files of my Test data. This should work with following SQL statement but the csv file is wrong.
BULK INSERT [DOK_FRASER]
FROM 'c:\Temp\DOK_FRASER.csv'
WITH
(
FieldTerminator = ';',
FIRSTROW = 2
)
GO
There are 2 problems with generated CSV file...
First is that the generated CSV file is doubling the columns (column names are doubled, the values are)
"FRASLOPNR";"FRASNAMN";"FRASNAMN";"FRASTEXT";"FRASTEXT";"GILTIGFROM";"GILTIGFROM";"GILTIGTOM";"GILTIGTOM"
"30";"Injektion ";"";"Injektion Behephan 1mg/ml, 1 ml subcutant.";"";"2008-05-06 00:00:00";"";"";""
the correct rows should look like
"FRASLOPNR";"FRASNAMN";"FRASTEXT";"GILTIGFROM";"GILTIGTOM"
"30";"Injektion ";"Injektion Behephan 1mg/ml, 1 ml subcutant.";"2008-05-06 00:00:00";""
Secound issue is scripting of values that are blobs. The BLOBs are not generated correctly. The value is scripted as "<Binary Data...>" instead of the real data.
Is this known\reported bug?
Regards,
Sanjin