Showing posts with label txt. Show all posts
Showing posts with label txt. Show all posts

Tuesday, February 14, 2012

command to load data from txt file to sql server 2005

Hi guys,

i would like to know the command used to load the data from the txt file to the sql server 2005.

Thanks in advance

Lalitha

Check this thread for suggestions:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1746695&SiteID=1

Friday, February 10, 2012

Comma Separated Output with .TXT extension

I have a somewhat strange situation where I need the output of a query thrown into a file with a .txt extension but I need the data in comma separate form. Any idea how I would get this accomplished?
Thanks in Advance,
TechRickIf you use bcp (from the command-line) you can specify the full filename

- Andy Abel|||You could use DTS. The fast way would be to choose the DTS Import/Export Wizard from the menu. Choose your source, then set your destination as a text file. Third select Query as your copy type, then input your query. Set your delimitor to be commas on the next screen. Then run, about 7 clicks to do.
You can also save the package to run again or edit it in DTS.|||Originally posted by achorozy
You could use DTS. The fast way would be to choose the DTS Import/Export Wizard from the menu. Choose your source, then set your destination as a text file. Third select Query as your copy type, then input your query. Set your delimitor to be commas on the next screen. Then run, about 7 clicks to do.
You can also save the package to run again or edit it in DTS.

Thanks so much for the info. I'm giving it a go but I'm running into an error. Perhaps you or someone else might know how to fix it.

Upon running the package I get this error: "Incomplete File Format Information - File Cannot Be Opened."

I don't know if this has anything to do with it, but I had to jimmy-rig the package to build it. I am using 3 temporary tables and 4 views in my query. DTS would not let me finish the package unless the main temporary table was already created. So, instead of having the query build it I just have the query delete and recreate it at the end so it is blank.

Any additional help would be appreciated.

TechRick|||Can you post the dts package ? Also, which version of sql server are you using - including service pack ?|||Originally posted by rnealejr
Can you post the dts package ? Also, which version of sql server are you using - including service pack ?

I am running 8.00.384 SP1 I believe.

Anyway, I was able to work it out by breaking the task up into smaller steps and running some of them through the job scheduler. I just had the last step run under the DTS package so I could get the output I wanted.

I had to break it up because I always seem to be above the 3200 charater limit for my queries to run as a job. Either my queries are too long or the job scheduler doesn't give enough characters...

Thanks for your assistance.

TechRick