Inserting a Delimited Text File into SQL Server 
Author Message
 Inserting a Delimited Text File into SQL Server

Hi

Is there any way in VC++, using which i can read and
insert a delimited
text file into a database assuming that the data in the
demilited text
file maps to the columns in the database table. Your input
will be
appreciated.

Thanks
Arun



Sun, 26 Dec 2004 04:05:22 GMT  
 Inserting a Delimited Text File into SQL Server

Quote:

>Hi

>Is there any way in VC++, using which i can read and
>insert a delimited
>text file into a database assuming that the data in the
>demilited text
>file maps to the columns in the database table. Your input
>will be
>appreciated.

You can always create SQL insert statements and then run ExcuteSQL()
on them.

Basic scheme:
1. Create a CDatabase linking to your target
2. Open the text file using a CStdioFile or a CFile in text mode
3. Read a line
4. Create a CString "insert into <table> values (<string>)"
5. ExecuteSQL()
6. If not EOF, get next line & goto 4.

You'll need the file to be delimited with single inverted commas,
otherwise you'll need to translate the delimeters.

HTH

Paul.
-------------------------------------------
Expressed opinions are usually my own.
Especially if they're any good (of course).
-------------------------------------------
NB Spam trap in e-mail address
-------------------------------------------



Sun, 26 Dec 2004 22:29:08 GMT  
 Inserting a Delimited Text File into SQL Server
Paul

Thanks for your reply, i am new to VC++ so i am asking this question. I
was reading on MSDN webpage about bulk insert and BCP functions are Sql
Server utilities so can i call these from the VC++ if yes then how can i
do it ??

Thanks
Arun Solleti

Quote:


> >Hi

> >Is there any way in VC++, using which i can read and
> >insert a delimited
> >text file into a database assuming that the data in the
> >demilited text
> >file maps to the columns in the database table. Your input
> >will be
> >appreciated.

> You can always create SQL insert statements and then run ExcuteSQL()
> on them.

> Basic scheme:
> 1. Create a CDatabase linking to your target
> 2. Open the text file using a CStdioFile or a CFile in text mode
> 3. Read a line
> 4. Create a CString "insert into <table> values (<string>)"
> 5. ExecuteSQL()
> 6. If not EOF, get next line & goto 4.

> You'll need the file to be delimited with single inverted commas,
> otherwise you'll need to translate the delimeters.

> HTH

> Paul.
> -------------------------------------------
> Expressed opinions are usually my own.
> Especially if they're any good (of course).
> -------------------------------------------
> NB Spam trap in e-mail address
> -------------------------------------------



Mon, 27 Dec 2004 04:06:53 GMT  
 Inserting a Delimited Text File into SQL Server

Quote:

>Paul

>Thanks for your reply, i am new to VC++ so i am asking this question. I
>was reading on MSDN webpage about bulk insert and BCP functions are Sql
>Server utilities so can i call these from the VC++ if yes then how can i
>do it ??

Sorry, I've never used these. I'd do it the way I outlined.

Paul.
-------------------------------------------
Expressed opinions are usually my own.
Especially if they're any good (of course).
-------------------------------------------
NB Spam trap in e-mail address
-------------------------------------------



Mon, 27 Dec 2004 19:28:14 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Inserting a Delimited Text File into SQL Server

2. Inserting a Delimited Text File into SQL Server

3. Trying to insert data into SQL Server

4. SQL Server: Slow INSERT performance??

5. Insert in SQL Server CTable<CDynamicAccessor>

6. OLEDB, Fail Insert, SQL Server 7

7. How to insert an image into SQL Server?

8. Inserting Muliple Records into SQL-SERVER Database

9. Inserting in to a SQL Server Database

10. connect to sql server and insert

11. How to insert image into SQL Server?

12. Inserting Binary data into SQL Server

 

 
Powered by phpBB® Forum Software