| Author |
Topic |
|
boblarson
Starting Member
17 Posts |
Posted - 2008-05-10 : 17:44:31
|
| Can you export the results of a stored procedure using BCP?If so, what is the syntax? If not, I was trying to convert my SP to a view, but it has a CASE statement within it and so I can't save a view with that (at least not as I've been trying).Thanks,Bob Larson |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-05-10 : 20:41:14
|
| You can try with osql or sqlcmd. |
 |
|
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2008-05-10 : 22:21:59
|
| bcp "exec database.dbo.stored_procedure" queryout"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
|
varshachyk
Starting Member
2 Posts |
Posted - 2008-12-22 : 10:47:17
|
| HI,I tried to execute the below command... bcp "sp_readerrorlog" queryout "H:\temp.dat" -c -Tbut i am getting below errorSQLState = 37000, NativeError = 170Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'sp_readerrorlog'.Please help me...shreeVarsha |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-22 : 10:54:08
|
| Why there is need of this? Error log are stored in Log folder in default folder for sqlserver?check location with properties of SQL error log. |
 |
|
|
boblarson
Starting Member
17 Posts |
Posted - 2008-12-22 : 12:52:33
|
quote: Originally posted by varshachykI tried to execute the below command... bcp "sp_readerrorlog" queryout "H:\temp.dat" -c -Tbut i am getting below errorSQLState = 37000, NativeError = 170Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'sp_readerrorlog'.
According to jhocutt, I think you should be using:bcp "exec YourDatabaseNameHere.dbo.sp_readerrorlog" queryout "H:\temp.dat" -c -TThanks,Bob Larson |
 |
|
|
varshachyk
Starting Member
2 Posts |
Posted - 2008-12-23 : 06:35:02
|
| hi,After changing tobcp "exec master.dbo.sp_readerrorlog" queryout "H:\temp.dat" -c -Ti am getting the below errorSQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one columnshreeVarsha |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2008-12-23 : 08:50:48
|
quote: Originally posted by varshachyk hi,After changing tobcp "exec master.dbo.sp_readerrorlog" queryout "H:\temp.dat" -c -Ti am getting the below errorSQLState = S1000, NativeError = 0Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one columnshreeVarsha
You'd need to store it in a table. Something like,create table ##test (a varchar(1000), b varchar(100))goinsert into ##testexec master.dbo.xp_readerrorloggoexec master..xp_cmdshell 'bcp "select * from ##test" queryout C:\7.txt -c -t -S servername -U username -P password'godrop table ##test |
 |
|
|
|