Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,085 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,543 people online right now. Registration is fast and FREE... Join Now!




BCP

 
Reply to this topicStart new topic

BCP, Need to create a CSV

blueletter
1 May, 2008 - 10:40 AM
Post #1

New D.I.C Head
*

Joined: 28 Nov, 2005
Posts: 22


My Contributions
Hello, I need to create a stored procedure that creates a csv file. this is the code I have so far.
CODE

CREATE PROCEDURE dbo.GetQuestionInfoCSV AS
BEGIN
declare @sql varchar(8000)
SET @sql = 'bcp "SELECT * FROM dbo.ISO_table" queryout C:\GetCSV.CSV -c -t, -T -S MANCHEST\SQLEXPRESS'
print @sql
EXEC master..xp_cmdshell @sql
END


and I get these errors on execution


SQLState = 42S02, NativeError = 208
Error = [Microsoft][SQL Native Client][SQL Server]Invalid object name 'dbo.ISO_table'.
SQLState = 42000, NativeError = 8180
Error = [Microsoft][SQL Native Client][SQL Server]Statement(s) could not be prepared.
NULL


Any help would much appreciated.
User is offlineProfile CardPM
+Quote Post

baavgai
RE: BCP
1 May, 2008 - 11:08 AM
Post #2

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,019



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
Can you execute this from a command line? Also, consider a username and password. When you run things like this, the security context is often not what you expect.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:06PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month