1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| create procedure toto @ID 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)+'.csv','/','-')
SET @bcpCommand = 'bcp "SELECT * FROM Produit, Details WHERE Produit.ID ="'+ @ID + '" and Produit.IDElem = Details.IDElem" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U jorj -P "jorj" -c'
end
--PRINT @bcpCommand
exec master..xp_cmdshell @bcpCommand |
Partager