[dba-SQLServer] Open a text file from SQL Server

Billy Pang tuxedo_man at hotmail.com
Wed Oct 6 13:02:48 CDT 2004


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



>From: "Michael Maddison" <michael at ddisolutions.com.au>
>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: Wed, 6 Oct 2004 22:36:14 +1000
>
>Arthur,
>
>Not sure what you mean by memory variable (in sql I think table) but a
>couple of ideas come to mind...
>Can you set up an OBDC connection to the text file and treat it as a
>linked server?
>Or DTS it into a table...
>
>cheers
>
>Michael M
>
>
>
>Can someone tell me how to open a text file from SQL Server? And place
>its contents into a memory variable? I'm looking at OPENXML but all its
>examples use text that is assigned to a variable from within the
>example, rather than read in from an XML or just a text file. It looks
>like full text search will do it, but that's a lot of install overhead
>just to read in a file. Is there a simpler way?
>
>TIA,
>Arthur
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>
>_______________________________________________
>dba-SQLServer mailing list
>dba-SQLServer at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
>http://www.databaseadvisors.com
>

_________________________________________________________________
Take charge with a pop-up guard 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*.




More information about the dba-SQLServer mailing list