Billy Pang
tuxedo_man at hotmail.com
Thu Oct 7 12:43:03 CDT 2004
ok.. I added dumped the results of xp_cmdshell into a variable called @the_value.. /* cut here */ declare @file_location varchar(255) declare @exec_stat varchar(255) declare @the_value nvarchar(255) declare @y INT declare @x int create table #tempResults(the_id int not null identity(1,1), the_value nvarchar(255)) SET @file_location = 'C:\myFile.txt' SET @exec_stat = 'type ' + @file_location insert into #tempResults EXEC master.dbo.xp_cmdshell @exec_stat select @y = count(*) from #tempResults set @x = 0 while @x <> @y begin set @x = @x + 1 select @the_value = the_value from #tempResults where the_id = @x select @x as row_num, @the_value as the_value end /* cut here */ >From: Arthur Fuller <artful at rogers.com> >Reply-To: dba-sqlserver at databaseadvisors.com >To: dba-sqlserver at databaseadvisors.com >Subject: Re: [dba-SQLServer] Open a text file from SQL Server >Date: Thu, 07 Oct 2004 09:32:47 -0400 > >Billy Pang wrote: > >>there is: >> >>declare @file_location varchar(255) >>declare @exec_stat varchar(255) >>SET @file_location = 'C:\myFile.txt' >>SET @exec_stat = 'type ' + @file_location >>EXEC master.dbo.xp_cmdshell @exec_stat >> >>note: it's not perfect because text in the variable is "word wrapped". >> >>Billy >> >Does this give me the contents of the file in a variable? That's what I >really need. Maybe it does, but I don't see how, or which variable will >contain the returned text. > >Arthur > >_______________________________________________ >dba-SQLServer mailing list >dba-SQLServer at databaseadvisors.com >http://databaseadvisors.com/mailman/listinfo/dba-sqlserver >http://www.databaseadvisors.com > _________________________________________________________________ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.