Exforsys

Online Training

how to transfer from flatfiles to sql server DB

This is a discussion on how to transfer from flatfiles to sql server DB within the SQL Server 2005 Tutorials forums, part of the Articles and Tutorials category; Hi I want to know how to transfert data from flatfiles to sqlserver DB explain with an example Manual procedure ...


Go Back   Exforsys > Articles and Tutorials > SQL Server 2005 Tutorials

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-07-2005, 07:59 AM
Junior Member
 
Join Date: Sep 2004
Posts: 13
rite2sekhar
how to transfer from flatfiles to sql server DB

Hi
I want to know how to transfert data from flatfiles to sqlserver DB

explain with an example Manual procedure not by im port method


Urgent Plz

Regds

Last edited by rite2sekhar; 03-07-2005 at 08:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-07-2005, 08:41 AM
admin's Avatar
Administrator
 
Join Date: Mar 2005
Location: New York, USA
Posts: 309
admin has disabled reputation
Send a message via Yahoo to admin
Right click on the database and you should see an option to import , select that, then you will be given options about the data source, select text file from that list and browse to your file. click next to select the destination db and the trabsformations.

if you have column names, you can check the box in wizard, import uses them as column names.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-07-2005, 02:11 PM
Senior Member
 
Join Date: Nov 2004
Posts: 177
sanereddy is an unknown quantity at this point
You can use the bulk insert creating the format files with the layout of your import file....

search for bulk insert in books online, the documentation is pretty good.


here is the sample format file and the stored procedure to read the file and load in SQL Server ....


Hope this helps.

Format File : save as text file and keep on the server some where to be accessable by SQl Server.

sample.fmt

8.0
5
1 SQLCHAR 0 1 "" 1 FIELD1 ""
2 SQLCHAR 0 5 "" 2 FIELD1 ""
3 SQLCHAR 0 4 "" 3 FIELD1 ""
4 SQLCHAR 0 4 "" 4 FIELD1 ""
5 SQLCHAR 0 10 "\r\n" 5 FIELD1 ""

This is the stored procedure which reads the import file and uses the format file , loads the data in toe sample_data table.

CREATE procedure sample_load as

BULK INSERT northwind..Sample_data FROM 'F:\Microsoft SQL Server\sample.txt'
WITH (
FORMATFILE = 'F:\Microsoft SQL Server\sample.fmt'
)



Hope this helps.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.