Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 saving as csv file from sql data base

Author  Topic 

bondwiththebest
Starting Member

46 Posts

Posted - 2007-06-20 : 08:49:12
HI every one,

I am pretty mcuh new to sql and I read all your previous replies..I jsut have my questions answered.If you can help me that would be great!

I can acces the date base using Server manager then retireve the data using the query .But now I need to convert that obtained the data into csv file n then save it into csv file.
IF you can help me out that would be great.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-20 : 08:52:58
You need to use BCP utility for that.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

bondwiththebest
Starting Member

46 Posts

Posted - 2007-06-20 : 10:55:03
I am not really sure how to use BCP. I need to code that in vb.net to obtain data and store it as an csv file.can u help me out ?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-06-20 : 10:57:41
Or in query analyzer, you can choose save query result to csv file.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-20 : 11:08:33
Something like this should work from command prompt:

bcp "<database-name>.dbo.<table-name>" out "test.csv" -q -t, -S<Server> -U<user-name> -P<Password> 


Also, do read about BCP utility in SQL Server help for understanding more options.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

bondwiththebest
Starting Member

46 Posts

Posted - 2007-06-20 : 14:13:09
hey I am really confused ..I need to write a prog in VB.net ,so i am not really sure how can i use query analyser or the command prompt.Can you provide me with a sample code.I have acces to the data base n using the query i can retrieve the data.The next step is saving in csv file.I really donno how to do that.Can you provide me with a sample code
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-06-20 : 15:19:45
Try posting your question in the .NET forum (at the bottom of the main forums page). You'll stand a better chance of getting an answer if you post in the proper forum.
Go to Top of Page
   

- Advertisement -