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 |
|
loiter99
Starting Member
38 Posts |
Posted - 2005-01-12 : 15:02:27
|
| Hello, Is it possible to have a stored procedure write it's results to a text file?thanksJ |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-01-12 : 16:28:50
|
| [code]USE NorthwindGOSET NOCOUNT ONCREATE TABLE myTable99(TABLE_NAME sysname)GOCREATE PROC mySproc99ASSELECT TABLE_NAME FROM INFORMATION_SCHEMA.TablesGOINSERT INTO myTable99(TABLE_NAME) EXEC mySproc99DECLARE @cmd varchar(8000)SELECT @cmd = 'bcp myTable99 OUT d:\test.dat -c -U -P -S'EXEC master..xp_cmdshell @cmdSET NOCOUNT OFFDROP PROC mySproc99DROP TABLE myTable99GO[/code]Brett8-) |
 |
|
|
loiter99
Starting Member
38 Posts |
Posted - 2005-01-13 : 09:04:21
|
| Thanks, I am getting this error though:Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'myTable99'.Thanks again |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-01-13 : 09:41:00
|
| Where are you executing the code from?Did you use Query Analyzer?Did you cut and paste the whole code snippet?Brett8-) |
 |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-01-16 : 14:56:47
|
| -- qualify the tablename:USE NorthwindGOSET NOCOUNT ONCREATE TABLE dbo.myTable99(TABLE_NAME sysname)GOCREATE PROC dbo.mySproc99ASSELECT TABLE_NAME FROM INFORMATION_SCHEMA.TablesGOINSERT INTO myTable99(TABLE_NAME) EXEC mySproc99DECLARE @cmd varchar(8000)SELECT @cmd = 'bcp northwind.dbo.myTable99 OUT d:\test.dat -c -U -P -S'EXEC master..xp_cmdshell @cmdSET NOCOUNT OFFDROP PROC mySproc99DROP TABLE myTable99GO |
 |
|
|
loiter99
Starting Member
38 Posts |
Posted - 2005-01-24 : 11:51:04
|
| I got it working .. thanks every. |
 |
|
|
|
|
|