Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read a text file into a field

Status
Not open for further replies.

billum

Programmer
Feb 4, 2003
31
US
Hi,

I want to get the contents of a text file(ascii) into a field in a table.
Is there a way to do it?

Plz help

Bill
 
DTS will do it. BCP might do it. Give us a little more.

Do you want to put the complete contents of a text file into a single cell of the database, like storing a document within the database?

Or do you have like a comma-separated file to be imported into multiple rows of the database, like a list of states to populate a States table? --Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
I want to store the contents of an entire text file to a database field which later I will be using as a message for email

bill
 
Billum, there are a few options.
I particularly use the bulk copy utility (BCP) and the BULK INSERT.

Search for those two topics in SQL BOL.

Hope this helps...
 
The length of the message varies ,Its actually textual matter the smallest is a file with 40 lines.
I tried using bulk insert , but didnt work.Its that each file is to be taken as message for each user.
(but first must be stored in a field)

Thnks
bill
 
Let me be more specific. How many characters will be in the file? Will it exceed 8000 characters? What is the schema of the table you need to insert this message into? How frequently wil this run? How do you intend to start the process to load the messsage?

Have you considered attaching the text file to the email and sending it as an attachment? If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Hi terry,

Sorry for the delay. It is a text field that Iam inserting into.I would like to do it thru a program ,only once.

Yes,I have tried attaching the file and it works.But I have to store the contents of the file in a field.
Thats what Iam aiming at.

Thanks
Bill

 
Check the following links.

HOWTO: Access and Modify SQL Server BLOB Data by Using the ADO Stream Object

HOWTO: Read and Write BLOBs Using GetChunk and AppendChunk

Microsoft included a utility program that copies text and image data in the SQL Server samples. See the articles at the following links. You don't even need to write code yourself.

Copy Text or Image into or out of SQL Server

TextCopy
If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top