Author |
Topic |
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 02:38:18
|
Hi.I use MS SQL Compact database server v3.5So I try to instert multiple rows in one Insert query. I get errer 25501.It works fine with one row like this:'INSERT INTO myTable VALUES ($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$')But this fails:'INSERT INTO myTable VALUES ($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$'),($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$'),($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$')'What could be wrong?Thanks!RegardsHans |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-18 : 02:54:07
|
I think there is no such kind of INSERT in SQL Server Compact...You can use insert....select values from anotherTableFollow this linkhttp://msdn.microsoft.com/en-us/library/ms174633(v=sql.105).aspx--Chandu |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-18 : 02:59:14
|
You can follow this kind of approach...INSERT INTO YourTableSELECT valuesUNION ALLSELECT valuesUNION ALLSELECT valuesUNION ALLSELECT values--Chandu |
|
|
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 03:58:02
|
I did try this, same error:'INSERT INTO myTable SELECT ($'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$') UNION ALL, SELECT ($'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$')'Any more tip?RegardsHans |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-18 : 04:27:17
|
Remove that comma....INSERT INTO myTable SELECT ($'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$') UNION ALL, SELECT ($'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$')--Chandu |
|
|
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 05:15:20
|
I did try that, same result, same errorRegardsHans |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-18 : 05:53:00
|
INSERT INTO myTable SELECT $'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$'UNION ALLSELECT $'2013.4.18 10:40:41:781$',$'FALSE$',$'FALSE$',$'FALSE$'--Chandu |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-04-18 : 06:06:14
|
What is this $ sign for? What error are you getting?CheersMIK |
|
|
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 08:45:52
|
Latest suggestion from Chandu gave error:26306 SSCE_M_QP_COERSIONERROR Data conversion failed. OLE DB status value (if known) Not applicable On the privious one I got:25501 SSCE_M_QP_BADPARSE There was an error parsing the query. Token line number, Token line offset Token in errorRegardsHans |
|
|
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 08:47:31
|
The $ signs is for using a variable as a parameter. This works fine.So it works fine when I just add one row, but I cant make it with multiple rows..RegardsHans |
|
|
hapetter
Starting Member
10 Posts |
Posted - 2013-04-18 : 08:54:47
|
Sorry guys, I found the problem. The last syntax suggestion from Chandu did work. I had a copy paste fault in the column definition type. Thank you for excelent help!RegardsHans |
|
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2013-04-18 : 09:06:55
|
I see, havn't used SS Compact edition. in standard/enterprise its "@" sign which is used with variables and perhaps can be changed via editor settings as well.Anyhow, if its the sign used with variable then there should have been values variables e.g. $paramter1,$parameter2, rather I see constant values? Both errors you mentioned are Engine related. Also, are you executing this query in management studio (SSMS)? or Passed via application or some other tool to the DB engineTry if you can execute the same query in below format INSERT INTO Table VALUES ($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$')INSERT INTO Table VALUES ($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$')INSERT INTO Table VALUES ($'2013.4.18 9:21:0:906$',$'FALSE$',$'FALSE$',$'FALSE$')CheersMIK |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-19 : 00:30:48
|
quote: Originally posted by hapetter The last syntax suggestion from Chandu did work. I had a copy paste fault in the column definition type. Thank you for excelent help!
Welcome--Chandu |
|
|
|