Tema: Re: Research - MSSQL failu saugojimas
Autorius: Raimis
Data: 2010-05-10 14:30:48
Cia pavyzdys rasymo i txt faila, gal tiks:

CREATE   PROC write_to_file
@msg VARCHAR(7999),
@file VARCHAR(100),
@overwrite BIT = 0
AS

/*
   Date written: January 12th 2001
  Purpose: To log messages to text files from stored
procedures/triggers/sql scripts
  Input parameters: message, file name, overwrite flag (1 to overwrite, 0
to append to file, 0 is the default)
  Example: EXEC write_to_file 'Duplicates found','C:\logfile.txt',0
  Tested on: SQL Server Version 7.0, 2000
  Remarks: You should have permissions required through access file system
through xp_cmdshell
           See SQL Server Books Online for xp_cmdshell if you are having
problems with this procedure


*/

BEGIN
SET NOCOUNT ON
DECLARE @execstr VARCHAR(255)
SET @execstr = RTRIM('echo ' + COALESCE(LTRIM(@msg),'-') + CASE WHEN
(@overwrite = 1) THEN ' > ' ELSE ' >> ' END + RTRIM(@file))
EXEC master..xp_cmdshell @execstr
SET NOCOUNT OFF
END

"Jornada Del Muerto" <ask@me.email> wrote in message 
news:hs8m6u$qnt$1@trimpas.omnitel.net...
>    Yra tokia mintis, kad is MSSQL kaikuria informacija loginti vykstant 
> funkcionalumui, pvz fiksuoti ivedama irasa ir kiekviena pakeitima, bet ne 
> i DB kad jos nereikalingai nepusti o i koki nors faila, gal kas zaide su 
> kokiu nors irasinejimu i failus is MSSQL? :) tai galetu but kad ir textine 
> db ar kita, pvz. xml (xml galima but ir paciam sukurinet su T-SQL pries 
> saugant), svarbu ji susikurinetu nuo 0 ir nereikalautu serve kazkokiu 
> papildomu libu.