February 11, 2011 at 1:12 pm
It works:
CREATE TABLE #TMP
(
MEMBID VARCHAR(20) NULL
)
INSERT #TMP
(MEMBID)
VALUES('111')
ALTER TABLE #TMP ADD PQI INT
------
But once adding update statement, I got an error said "Invalid column name 'PQI'"
CREATE TABLE #TMP
(
MEMBID VARCHAR(20) NULL
)
INSERT #TMP
(MEMBID)
VALUES('111')
ALTER TABLE #TMP ADD PQI INT
UPDATE #TMP
SET PQI = 1
February 11, 2011 at 1:19 pm
I copied and pasted your script directly into my SSMS 2005... and don't get a failure. No idea why this is breaking.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
February 11, 2011 at 1:25 pm
in this specific example, i cannot get it to raise the error, but I've encountered other situations where i must issue the GO command after an ALTER TABLE command before I was able to do DML operations to the table i issued DDL commands against; it's weird that it's not raising the error, because I'm sure I'd seen it before;
Lowell
February 11, 2011 at 1:32 pm
I believe the OP is seeing the error in SQL Server Management Studio prior to execution.
I copied the script in and on the line:
SET PQI = 1
PQI is underlined in RED. Placing your cursor over it displays the error.
Just execute it.
February 11, 2011 at 1:33 pm
You are right.
After adding "go", it works fine.
What is happend?
Does SQL have refresh table command?
February 11, 2011 at 1:39 pm
adonetok (2/11/2011)
You are right.After adding "go", it works fine.
What is happend?
Does SQL have refresh table command?
Original, non-modified version of #TMP may have still been in memory. Usually when I get odd behavior like that I make sure all my current #table are dropped and retry.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply