Solved

SQL Server Schedule job to dump txt data into a table

Posted on 2002-04-18
4
302 Views
Last Modified: 2012-06-27
Hi

It would great if someone could help me out as to how to load a text file with comma delimeted into a table on  SQL Server  and to run a scheduler to do this job every day

Thanks
0
Comment
Question by:Richards
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 6950302
First, how can data be loaded:
* BCP (a command line tool, see books online how this works)
* BULK INSERT (a TSQL command, same as BCP)
* DTS (a feature in SQL Server to load data using ODBC driver/OLEDB interface)

When you have choosen/tested those functions, you can then automate this process:
* BCP: create a job, with one step. The step can be of type Command, and you only type in the command to run BCP with all the options.
* BULK INSERT: same as BCP, only that you have a step of type TSQL, and give the TSQL line needed
* DTS: once you have your DTS package ready, just right-click it and choose schedule. See in the job list a new job that you might customize regarding the schedule.

Tip:
load the data always to a staging table, which doesn't check for data consistency and data types immediately. Do these kind of checks after loading, and then copy/move the records to the final table.

CHeers
0
 

Author Comment

by:Richards
ID: 6950329
Thanks ! Can I have an example of any of them say I have in a text file text.txt in C:\

record 1 , RollNo , Name , age
record 1 , RollNo , Name , age

and a table name test which have the four fields

How can I use the DTS to do it . Is there any documentation for it ?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6950368
For SQL DTS docu on the web:
http://www.sqldts.com/

A simple example of BULK INSERT:
BULK INSERT test from 'c:\test.txt'
WITH FIELDTERMINATOR = ',' , FIRSTROW = 1

With BCP:
BCP yourdb..test IN "c:\test.txt" -F 1 -t "," -S server_name-U login_id -P password -

CHeers
0
 

Author Comment

by:Richards
ID: 6952834
Thanks ! Can you let me know where will i insert the sql and how to run the Scheduler?
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question