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

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What can I use to seperate INSERT queries

Author  Topic 

dsylebee
Starting Member

8 Posts

Posted - 2009-12-01 : 10:15:16
HI all

I was wondering I have a Query that I am sending from my C++ application it's TSQL for MS Access I seperated my INSERT INTO's

with a ; it gives me a CHAR WAS FOUND AT THE END OF INSERT SYNTAX

I'd like to know what I need to use to seperate my queries in order to be able to send many queries at a time thanks in advance.

What I currently have and fails.


First chance exception at $7C812AFB. Exception class EOleException with message 'Characters found after end of SQL statement'. Process LCSBO_pro.exe (4344)



Debug Output:
INSERT INTO [TSAM-File] VALUES ( 0, 'ENTREES', '', '4709160',40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 1, 'SALADES', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 2, 'LES A COTES', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 3, 'GRILLADES', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 4, 'POISSONS FR ', ' MER', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 5, 'VEAU', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 10, 'PATES', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 11, 'POULET BBQ', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 12, 'MENU ENFANT', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 6, 'EXTRAS', '', '0', 40960, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 51, 'BAMBINO COMBO', '', '0', 180, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 52, 'PIZZA PETITE', '', '0', 180, 0, 0, 0);
INSERT INTO [TSAM-File] VALUES ( 53, 'PIZZA MOYENNE', '', '0', 180, 0, 0, 0);

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-12-01 : 10:30:41
You shouldn't need to sperate them with anything.

You could also do:

INSERT INTO [TSAM-File]
SELECT 0, 'ENTREES', '', '4709160',40960, 0, 0, 0
UNION SELECT 1, 'SALADES', '', '0', 40960, 0, 0, 0
UNION SELECT 2, 'LES A COTES', '', '0', 40960, 0, 0, 0
Go to Top of Page

dsylebee
Starting Member

8 Posts

Posted - 2009-12-01 : 10:36:34
quote:
Originally posted by RickD

You shouldn't need to sperate them with anything.

You could also do:

INSERT INTO [TSAM-File]
SELECT 0, 'ENTREES', '', '4709160',40960, 0, 0, 0
UNION SELECT 1, 'SALADES', '', '0', 40960, 0, 0, 0
UNION SELECT 2, 'LES A COTES', '', '0', 40960, 0, 0, 0




K i removed the ;'s

and now I get this

First chance exception at $7C812AFB. Exception class EOleException with message 'Missing semicolon (;) at end of SQL statement'. Process LCSBO_pro.exe (1824)

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-01 : 11:05:59
Maybe it is only the ; at the LAST statement?

Why do you not try like Rick says: UNION?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

dsylebee
Starting Member

8 Posts

Posted - 2009-12-01 : 11:13:24
quote:
Originally posted by webfred

Maybe it is only the ; at the LAST statement?

Why do you not try like Rick says: UNION?


No, you're never too old to Yak'n'Roll if you're too young to die.



I tryed a ; at the last one.

Debug Output: INSERT INTO [TSAM-File] (Box#, Line1, Line2, ColorDesc, Color, ForeColorm ColorNum, formeboutton) SELECT 0, 'ENTREES', '', '4709160', 40960, 0, 0, 0 UNION ALL SELECT 1, 'SALADES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 2, 'LES A COTES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 3, 'GRILLADES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 4, 'POISSONS FR ', ' MER', '0', 40960, 0, 0, 0 UNION ALL SELECT 5, 'VEAU', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 10, 'PATES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 11, 'POULET BBQ', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 12, 'MENU ENFANT', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 6, 'EXTRAS', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 51, 'BAMBINO COMBO', '', '0', 180, 0, 0, 0 UNION ALL SELECT 52, 'PIZZA PETITE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 53, 'PIZZA MOYENNE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 50, 'PIZZA GRANDE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 54, 'PIZZA X-GRANDE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 42, 'SOUS-MARINS', '', '0', 13107200, 0, 0,  Process LCSBO_pro.exe (4972)
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-01 : 11:18:55
Try UNION please - it is much better.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

dsylebee
Starting Member

8 Posts

Posted - 2009-12-01 : 11:27:39
quote:
Originally posted by webfred

Try UNION please - it is much better.


No, you're never too old to Yak'n'Roll if you're too young to die.



this does not work it gives syntax's errors

the way he did it without the (Box#, Line1, Line2, ColorDesc, Color, ForeColorm ColorNum, formeboutton)

gives a Error saying distination fields missing s to put those :)

Debug Output: INSERT INTO [TSAM-File] (Box#, Line1, Line2, ColorDesc, Color, ForeColorm ColorNum, formeboutton) SELECT 0, 'ENTREES', '', '4709160', 40960, 0, 0, 0 UNION ALL SELECT 1, 'SALADES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 2, 'LES A COTES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 3, 'GRILLADES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 4, 'POISSONS FR ', ' MER', '0', 40960, 0, 0, 0 UNION ALL SELECT 5, 'VEAU', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 10, 'PATES', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 11, 'POULET BBQ', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 12, 'MENU ENFANT', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 6, 'EXTRAS', '', '0', 40960, 0, 0, 0 UNION ALL SELECT 51, 'BAMBINO COMBO', '', '0', 180, 0, 0, 0 UNION ALL SELECT 52, 'PIZZA PETITE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 53, 'PIZZA MOYENNE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 50, 'PIZZA GRANDE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 54, 'PIZZA X-GRANDE', '', '0', 180, 0, 0, 0 UNION ALL SELECT 42, 'SOUS-MARINS', '', '0', 13107200, 0, 0, Process LCSBO_pro.exe (4972)
Go to Top of Page

dsylebee
Starting Member

8 Posts

Posted - 2009-12-01 : 12:11:01
I changed the methods programming side it's now just looping trough an array and sending one query at a time thanks for your time anyways.
Go to Top of Page
   

- Advertisement -