| Author |
Topic |
|
bsav
Starting Member
7 Posts |
Posted - 2004-08-26 : 14:22:11
|
| I think I've narrowed my problem down. I do an "alter table add column", then the next statement tries to do an "update" to that column. The update says the column doesn't exist though. Here's the script:if(1=1)BEGINALTER TABLE CCAuths ADD CCNumTmp varbinary(32) DEFAULT 0 NOT NULLUPDATE CCAuths SET CCNumTmp = CONVERT(varbinary(32), CCNum)ENDGOBSav |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-26 : 14:36:58
|
| try putting GO between Alter and update.Go with the flow & have fun! Else fight the flow :) |
 |
|
|
bsav
Starting Member
7 Posts |
Posted - 2004-08-26 : 14:41:53
|
| Yea, can't get that to fly syntax wise:Server: Msg 170, Level 15, State 1, Line 12Line 12: Incorrect syntax near 'NULL'.Server: Msg 156, Level 15, State 1, Line 3Incorrect syntax near the keyword 'END'. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-26 : 14:43:13
|
| ALTER TABLE CCAuths ADD CCNumTmp varbinary(32) DEFAULT 0 NOT NULLGOUPDATE CCAuths SET CCNumTmp = CONVERT(varbinary(32), CCNum)GOTara |
 |
|
|
bsav
Starting Member
7 Posts |
Posted - 2004-08-26 : 14:46:00
|
| Yes, that's exactly what I did, and got the error mentioned above. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-26 : 14:50:08
|
| ahh that's because of the ifGo with the flow & have fun! Else fight the flow :) |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-26 : 14:50:56
|
| this should do it:if(1=1)BEGINalter table customers add bla varchar(200)endgoif(1=1)BEGINupdate customers set bla = ContactNameendGo with the flow & have fun! Else fight the flow :) |
 |
|
|
bsav
Starting Member
7 Posts |
Posted - 2004-08-26 : 14:54:30
|
| Why does the if cause this problem? What don't I understand? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-26 : 14:55:26
|
| Yep, it's not exactly what you did as you still had the IF. When the GO runs, it breaks out of it.Tara |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-08-26 : 14:56:30
|
| as i get it go starts the new batch and if can't be in different batches.Go with the flow & have fun! Else fight the flow :) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2004-08-26 : 14:56:57
|
| It causes a problem because the BEGIN doesn't have a corresponding END. Here is how SQL executed it:IF (1=1)BEGIN ALTER GOSo the above ran and there was no corresponding END.Tara |
 |
|
|
bsav
Starting Member
7 Posts |
Posted - 2004-08-26 : 15:00:58
|
| Ahhhh! I see! Thanks all! |
 |
|
|
|