Friday, January 19, 2007

SQL Server: export Resultsets into Text file and Retrieve back

create table #errorlog(line varchar(2000))
execute master.dbo.xp_cmdshell 'osql -S10.1.1.6 -E -Q"execute PSIWebV3.dbo.sp_Test" -o"c:\temp\sp_out.txt" -s"" '
insert into #errorlog
execute master.dbo.xp_cmdshell 'type "c:\temp\sp_out.txt" '
select line from #errorlog

No comments:

Post a Comment