?
Solved

SQL Server Schedule job to dump txt data into a table

Posted on 2002-04-18
4
Medium Priority
?
303 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 400 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, we’ll look at how to deploy ProxySQL.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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