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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Save stored prodeure result as file
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chiragvm
Yak Posting Veteran

India
65 Posts

Posted - 12/13/2012 :  04:53:23  Show Profile  Reply with Quote
i have a Stored Procedure , in proc Print certain result like

Print '-- Start Transection--'
Print 'Transection No = ' + @TransectionId     
...
...
Print 'Transection Success'
Print '-- End Transection--'

is it possible to Save printed result in a file while call it from UI. after that we have to mail that file to user also ask for download that file

-------------
Chirag
India
Sr. Web Engineer

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3383 Posts

Posted - 12/13/2012 :  05:01:49  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
Yes.
You can bcp the result out.
Use sqlcmd to run it and output to a file
Use it as a source in ssis
Use reporting services
...



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 12/13/2012 :  05:02:24  Show Profile  Reply with Quote
Check this link http://www.nigelrivett.net/SQLTsql/WriteTextFile.html

--
Chandu
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 12/13/2012 :  05:22:41  Show Profile  Reply with Quote
One example is as follows:

GO
CREATE PROC test_Proc
AS
BEGIN
SELECT 'example for writting procedure output to a file'
END
GO
EXEC master..xp_cmdshell
'bcp "EXEC [DBName].[dbo].[YourSPName] " queryout "D:\temp\file.txt" -c -S "YourServerName" -T'

Change file path and then execute it

http://social.msdn.microsoft.com/Forums/en-US/sqlgetstarted/thread/e2d012d5-51d8-4a63-99cc-e76d8498ef94/

--
Chandu

Edited by - bandi on 12/13/2012 05:23:44
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000