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.
| Author |
Topic |
|
raulbolanos
Starting Member
6 Posts |
Posted - 2009-06-16 : 08:49:29
|
| Hi guys,I need to make a query with this algorythm whithin one single String.IF X < 18Start DELETE from School WHERE age = 17; DELETE from Party WHERE hobby = 'alcohol'; DELETE from Girls WHERE hair = 'blodes';EndINSERT School (age, name) VALUES(17, 'RaiL');INSERT Party (drink, name) VALUES('soda', 'RaiL');INSERT Girls (girls, name) VALUES('none', 'RaiL');Any idea? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-16 : 08:55:24
|
[code]IF @x < 18 BEGIN DELETE from School WHERE age = 17 DELETE from Party WHERE hobby = 'alcohol' DELETE from Girls WHERE hair = 'blodes' ENDINSERT School (age, name) VALUES(17, 'RaiL')INSERT Party (drink, name) VALUES('soda', 'RaiL')INSERT Girls (girls, name) VALUES('none', 'RaiL')[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
raulbolanos
Starting Member
6 Posts |
Posted - 2009-06-16 : 09:18:25
|
| I already try that, but I get an 1064 Error :( |
 |
|
|
raulbolanos
Starting Member
6 Posts |
Posted - 2009-06-16 : 09:19:32
|
| by the way, every different Query need a semicolon ';' at the end? in this case we need 6. |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2009-06-16 : 09:41:33
|
| 1064 error? Something like:"You have an error in your SQL syntax; check the manual that corresponds to your MySQLserver version for the right syntax to use near...."Are you using MySql?Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|
|