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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-02-27 : 12:37:51
|
| dave writes "I used your code to get bcp to work. I want to be able to query a table and drop it to a file for word to pick up and mail merge letters and labels.The bcp code worked in query analyzer:DECLARE @FileName varchar(50), @bcpCommand varchar(2000) SET @FileName = REPLACE('d:\tapeministry\test8898989_1001_'+ CONVERT(char(8),GETDATE(),1)+ '.txt','/','-') SET @bcpCommand = 'bcp "SELECT * FROM tapeministry.dbo.trans_dump" queryout "' SET @bcpCommand = @bcpCommand + @FileName + '" -U... -P... -c' EXEC master..xp_cmdshell @bcpCommandMy next move was to be able to call this from an asp page. I made this into a sp and when I called it from vbscript I could not get past permissions errors. Here is the final error I can't get past...( I even gave my user permissions to the xp_cmdshell in the master db.xpsql.cpp: Error 87 from GetProxyAccount on line 604 Any ideas? Is there another wa;y or easier way to do this?Thanks,Dave Welch" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-02-27 : 13:06:09
|
| Take a look here:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=23773Basically if you're calling this from ASP you can pass the query via an ADO Recordset, convert that recordset to tab- or comma-delmited using the GetString() method, and write it out to a file the user can download, or just Response.Write it directly to their browser. The code you need will be in that link and the additional links in that thread. You won't need to use bcp at all.Edited by - robvolk on 02/27/2003 13:06:36 |
 |
|
|
|
|
|