Et voilà la fonction qui va bien !
Cette procédure stockée permet d'exporter le contenu d'une table dans un fichier texte.
Pour avoir cherché un moment... y'a pas plus direct.
Sinon pense à un DTS...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
create procedure _Tbl2Txt @t nvarchar(128)
as
begin
--Ecrit le contenu d'une table passée en paramètre dans un fichier texte
declare
@FileName varchar(50),
@bcpCommand varchar(2000)
set @FileName = replace('c:\res_' + convert(char(8), getdate(),1)+'.txt','/','-')
set @bcpCommand = 'bcp "' + @t + '" out "'
set @bcpCommand = @bcpCommand + @FileName + '" -U sa -P "pwd" -c'
end
--PRINT @bcpCommand
exec master..xp_cmdshell @bcpCommand |
En espèrant que cela te serve...