Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reading text files in T-SQL
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 08/24/2001 :  10:27:56  Show Profile  Visit AskSQLTeam's Homepage  Reply with Quote
Kumar writes "I would like to set a variable equal to the contents of a text file (stored on the file system) in T-SQL. Can you help ?

The text file will contain an XML document.
I need to read the text file into a variable so that it can be passed to the sp_xml_preparedocument stored proc.
I can't figure out how to read a text file and assign the contents to a variable.


Thanks
Kumar.

SQL 2000 / Win2000 Server.


"

nizmaylo
Constraint Violating Yak Guru

USA
258 Posts

Posted - 08/24/2001 :  15:56:44  Show Profile  Reply with Quote
Try reading BOL on READTEXT, TEXTPTR, etc.

helena
Go to Top of Page

nizmaylo
Constraint Violating Yak Guru

USA
258 Posts

Posted - 08/24/2001 :  16:10:30  Show Profile  Reply with Quote
I read you question again and it sounds you don't know where to begin.

1.bcp your file in a text format into a staging area (permanent or global temporary table) using a stored procedure (you could put it into a job)
2. read your text file into a variable using READTEXT

helena
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000