September 8, 2008 at 6:01 pm
Trying to change multiple values in a table based on values that are there....
Ok here is example:
update Table_A
set Field_Q = 'ZZZ'
where (Field_Q = 'XXX')
GO
update Table_A
set Field_Q = 'TTT'
where (Field_Q = 'ttt')
GO
update Table_A
set Field_Q = 'GGG'
where (Field_Q = 'rrr')
GO
GO gives error in Sql Server Mgmt Studio. If I remove them parser has problem, creating 'nested' statement that then does nothing.
Have a large number of changes like this to make along with programming changes to use the updated table. Want to script changes, because I will then have to distribute to multiple users.
Probably something simple I have missed or am just unaware of, looking for enlightenment.
Thanks :ermm:
September 8, 2008 at 9:19 pm
What is the error you are getting?
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
September 8, 2008 at 10:38 pm
Could you post the exact code as well, the only time I had problems with go was within dynamic SQL... so that is most likely not the problem!
September 9, 2008 at 8:44 am
Popup MessageBox said 'syntax error near GO' for each of the GO statements.
I am not at office now, will post EXACT error in a few hours when I get in.
Thanks for the help.
September 9, 2008 at 8:56 am
September 9, 2008 at 8:56 am
September 9, 2008 at 9:25 am
I agree that those aprenthesis are useless in that context, but that's not the problem here.
September 9, 2008 at 1:25 pm
Can't put 'exact' code I am trying to run, due to company security, but code example above is exact, other than table and column names.
The parans are there because SQL Syntax check insert them, if I check each stement individually. Didn't think they were needed, but didn't think it made a difference.
When I click the 'Verify SQL Syntax' button in Mgmt Studio I get a popup that says:
"Incorrect syntax near 'GO'." for each of the GO entries in the statement/script.
Am I having a problem, because I am selecting based on, and trying to change the same column?
Is there a differnet process/methodology for this case?
This seems to be my only option, because there are multiple entries with the values I am trying to change. But no unique identifier other than that column.
Thanks
September 9, 2008 at 1:36 pm
Two ideas:
In the real code, is there anything else on the line with 'GO"? If so, remove it.
Does it complain if the 'GO' is lower case?
September 9, 2008 at 1:42 pm
nothing else on line with GO, will try lower case.
Thanks.
September 9, 2008 at 2:24 pm
Where exactly in SSMS are you building this query? I have never seen a popup window when I have syntax errors - rather, the results pane will show the error message instead.
If you are not using a query window - then the reason you would be getting this error is because GO is not recognized as a batch terminator in that tool.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
September 10, 2008 at 11:46 am
Solved problem. I was being stupid.
Was 'Opening' table in Mgmt Studio, and running script in window.
When I check syntax/run in query new query window seperate from table, with just db selected, no syntax/parsing problems and runs fine.
Thanks for help. Sorry to have wasted your time. 😀 😉 😀
September 10, 2008 at 11:47 am
Thanks, Jeffrey!
September 10, 2008 at 11:52 am
Well all did that, at least once.
I was most fortunate to have blocked out that sad memory... it all case screaming back at me. :hehe:
Thanks for letting us know :w00t:.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply