Solved

SQL Server Schedule job to dump txt data into a table

Posted on 2002-04-18
4
292 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
  • 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adding queries and macros to many Microsoft Access Databases. 7 86
ODBC Question 3 49
use lov values 2 64
Querying data from 3 SQL tables 2 39
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Read about achieving the basic levels of HRIS security in the workplace.
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…
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…

820 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