Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Server Schedule job to dump txt data into a table

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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