1

I have a tab separated .txt (Very Small file with just 10 to 15 datasets) and this file is having some columns as PrdName, PrdSize, PrdWeight, PrdCode and so on.

Now I want to import the two columns which are PrdSize and PrdCode and import it in the columns of my Database table. I have created the columns but how do I create import clause and transfer data from .txt file to SQL Server? Thanks

3 Answers 3

1

Take a look at this post: Import/Export data with SQL Server 2005 Express, there are multiple options that you can use.

Sign up to request clarification or add additional context in comments.

8 Comments

I see, I'll download the specified Toolkit then...Thanks
In SQL Server 2000, you can right click on the database in Object Explorer and choose Tasks - Import Data ...
All right, well then I'll do this way. So how about Import Clause, do I need to create import clause after the import data? Is it possible in this Management studio?
Jasmine, you can save it as a package at the end of the wizard and then execute this package as a job or from you procedure. But what is your ultimate goal? Is it one time load or long term automated solution?
Jasmine, you can't create SSIS package in SQL Server 2000, but you can create DTS package (similar, but older technology). See msdn.microsoft.com/en-us/library/… for SSIS/DTS Compatibility in SQL Server 2005 Express.
|
1

Since you have the express edition you'll need to either use BCP or write a program with something else.

2 Comments

Would it be possible to perform this task on SQL Server 2000? I've that also in a different computer. It's basically a very small .txt file.
@Jasmine Appelblad SQL 2000 DTS has a FileSource, but I don't know if the destination can be SQL 2005 express. You should try it and see
1

If you have a large amount of data, or need to automate the process, definitely look into BCP as mentioned already. However, I often use excel to load one-time data sources (a few hundred to a few thousand) rows of data from odd sources into SQL Server by doing the following:

Get the data into excel (that's usually easy), assuming you get column A with 'Prdsize' and column B with PrdCode, in column C put the formula:

="INSERT INTO MYTABLE(PRDSIZE, PRODCODE) VALUES (" & a1 & "," & B1 & ")" 

(in other words create syntactically correct SQL using an Excel formula - you may need to add quotes around string values etc)

and then paste that formula all the way down the column C. Then copy/paste the resultant sql insert statements into SQL Management Studio, or any other tool that can execute SQL and execute it.

Defintely a 'manual' effort, but for one-time data loads it words great.

PS: You'll need to verify the XL formula and the resultant sql syntax - my example is close, but I didn't test it.

alt text

1 Comment

Thank you EJB. The .txt file is very small but I need to go from the procedure only. Need to create an Import clause only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.