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 |
|
a4u6178
Starting Member
11 Posts |
Posted - 2011-11-15 : 01:41:42
|
| hi Create text file in client machine instead of server how to do this alter Procedure [dbo].[USP_SaveFile](@text as NVarchar(Max),@Filename Varchar(200)) ASBegin declare @Object int, @rc int, @FileID Int EXEC @rc = sp_OACreate 'Scripting.FileSystemObject', @Object OUT EXEC @rc = sp_OAMethod @Object , 'OpenTextFile' , @FileID OUT , @Filename , 2 , 1 Set @text = Replace(Replace(Replace(@text,'&','&'),'<' ,'<'),'>','>') EXEC @rc = sp_OAMethod @FileID , 'WriteLine' , Null , @text Exec @rc = [.net trainee emp000].dbo.sp_OADestroy @FileID Declare @Append bit Select @Append = 0 If @rc <> 0 Begin Exec @rc = [databasename].dbo.sp_OAMethod @Object, 'SaveFile',null,@text ,@Filename,@Append End Exec @rc = [databasename].dbo.sp_OADestroy @Object End -- Use [databasename] -- EXEC sp_configure 'show advanced options', 1 --GO --EXEC sp_configure 'Ole Automation Procedures', 1; --GO -- RECONFIGURE; --GO --EXEC USP_SaveFile 'Microsoft SQL Server 2008', 'D:\sqlfiles\test.txt'the above stored procedure will create text file but i am not having permission to see created file because it is saved in sql server now i want to save in local machine how can achieve this .. pls help meThanks & Regards, |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-15 : 03:12:56
|
| try using UNC path of shared path created in your local machine which is accessible from the server------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|