Wednesday, March 7, 2012

help moving comma delimited data

I posted this originally in the incorrect forum I believe so I am reposting this in here which I believe is the proper place.

I need to move essentially a flat file from one server to another one and export it into a database on the second server. Does anyone have an easy process to accomplish this? I am currently at a loss. Any advice would be much appreciated.

Thanksuse BCP to create the export-flat-file
and the Bulk Insert command to import it in the other database|||I can give you examples if this is what you need|||Not that I'm a fan of it...but DTS?

I like Karolyn's idea better though...

Just make sure the server is mapped...|||learned my lessons well...
dts, bcp, bulk insert, ...
i'm getting there !|||Yeah, I almost exclusivley use bcp...

Where in France?|||Originally posted by Brett Kaiser
Yeah, I almost exclusivley use bcp...

Where in France?

Thanks Karolyn and Brett. Much appreciated. This may be a really silly question, but what does BCP stand for?|||BCP: Bulk Copy Program (Very original, huh)

DTS: Data Transformation Service

DDL: Data Definition Language

DML: Data Manipulation Language

DCL: Data Control Language

BOL: Books Online

M$: Evil Empire (But hey, it pays the bills)

IBM: (HAL +1)

OS/2: Whatever happend to that great OS

NT: Nice Try...but no OS/2

DB2: Bullet proof RDBMS

MOO: My Own Opinion...

Democratic Convention: Loony Bin

George Bush: Evil Doer seeker (It's embarrassing)|||Originally posted by Brett Kaiser
BCP: Bulk Copy Program (Very original, huh)

DTS: Data Transformation Service

DDL: Data Definition Language

DML: Data Manipulation Language

DCL: Data Control Language

BOL: Books Online

M$: Evil Empire (But hey, it pays the bills)

IBM: (HAL +1)

OS/2: Whatever happend to that great OS

NT: Nice Try...but no OS/2

DB2: Bullet proof RDBMS

MOO: My Own Opinion...

Democratic Convention: Loony Bin

George Bush: Evil Doer seeker (It's embarrassing)

lol thanks Brett my day is now complete :)|||Example of Bulk Insert

Bulk Insert Base.Proprio.Table
From 'Path + File to Import'
With (FieldTerminator = ',',
RowTerminator = ',\n',
CodePage = 'ACP',
TabLock) ;|||Example for BCP :

DECLARE @.cmd varchar(8000), @.sql varchar(8000);

Select @.sql = '"Select ' + '''Folio''' + ' + ' +
'Left(DTMAJL,19)' + ' + ' +
'''Date extraction''' + ' + ' +
'''N de table''' + ' + ' +
'''Table''' + ' + ' +
'''Version''' + ' as Entte, ' +
' * ' +
'From Base..Table ' +
'Where DTMAJL > (Select DTLOTVAL From Base..V89TBPL0) And DTMAJL is not NULL"';

SET @.cmd = 'bcp ' + @.sql
+ ' queryout ' + 'Chemin et nom du fichier gnrer'
+ ' -c -t ' + 'bidule carr'
+ ' -r ' + 'bidule carr\n'
+ ' -U ' + 'username' +' -P ' + 'password' +' -S ' + @.@.servername
+ ' h ' + '"TABLOCK"';

EXEC master..xp_cmdshell @.cmd;|||Originally posted by Karolyn
Example for BCP :

DECLARE @.cmd varchar(8000), @.sql varchar(8000);

Select @.sql = '"Select ' + '''Folio''' + ' + ' +
'Left(DTMAJL,19)' + ' + ' +
'''Date extraction''' + ' + ' +
'''N de table''' + ' + ' +
'''Table''' + ' + ' +
'''Version''' + ' as Entte, ' +
' * ' +
'From Base..Table ' +
'Where DTMAJL > (Select DTLOTVAL From Base..V89TBPL0) And DTMAJL is not NULL"';

SET @.cmd = 'bcp ' + @.sql
+ ' queryout ' + 'Chemin et nom du fichier gnrer'
+ ' -c -t ' + 'bidule carr'
+ ' -r ' + 'bidule carr\n'
+ ' -U ' + 'username' +' -P ' + 'password' +' -S ' + @.@.servername
+ ' h ' + '"TABLOCK"';

EXEC master..xp_cmdshell @.cmd;

Thanks Karolyn and Brett for all the help. Time to see if I can get this to work :)|||Say I need to have a sql server just listen for updates that are made in a web server. Currently these two are on seperate boxes but I need to have data passed only from the web server to the sql server. Using the load command is there a simple way to have the sql server continually listening for updates while keeping security high and preventing any possible accidents to the sql database.

Web server takes input, the sql server listens for updates to the web server and when updates take place the sql server imports the data for storage and review at later dates.

Does that make sense?

Would setting up a virtual drive as a holding area and then just pointing the sql database be a good option for this?

Thanks again for all the prior help.|||How would SQL Server "see" The Web Changes?

Where is the Web Data stored? And why is it not stored in SQL Server in the first place? Doesn't the app talk to the database?|||Originally posted by Brett Kaiser
How would SQL Server "see" The Web Changes?

Where is the Web Data stored? And why is it not stored in SQL Server in the first place? Doesn't the app talk to the database?

The web server and database server are linked using a ODBC connection. What happens is that the data when inputed on the web server is being saved to the web server just not being send to the database server. Can the Load Data Infile command be used to import data to the databse server from the web server with an ODBC connection? I am not having much luck finding that information on the net.

Thanks|||Brett: Wasn't OS/2 only half an operating system? ;-)|||True multitasking...

Ahhh the good old days...

Toasted Onion (I think that's a cool handle)

What do you mean "Load Data Infile"

Not much of a presentation layer guy...just a lowly dba scrub....|||I read on the mysql website and in other forums that you can use the Load Data Infile command to import data from text files like excel and such.|||Originally posted by Brett Kaiser
True multitasking...

Ahhh the good old days...

Toasted Onion (I think that's a cool handle)

What do you mean "Load Data Infile"

Not much of a presentation layer guy...just a lowly dba scrub....

i like that scrubby look ;)

No comments:

Post a Comment