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 |
|
Cornelius19
Starting Member
30 Posts |
Posted - 2008-12-09 : 16:33:49
|
Hi,Here is a simplified version of my script:--Part OneCREATE TABLE [MyTable] ( [word] [nvarchar] (50) COLLATE Latin1_General_CS_AS NULL ) ALTER TABLE MyTableADD MyColumn nvarchar(1)--Part TwoUPDATE MyTableSET MyColumn = 0 I can execute it successively: part one first and part two after without error. However, when I try to execute the whole, I got an “Invalid column name 'MyColumn'.” message. Is there any way to run a script containing first an ADD command and than an UPDATE command?CorneliusP.-S. I know that there are many ways to reach the same results as the above script does without having ADD and UPDATE (like including the new column when the table is created). However, the actual script is more complex: the table is not created by CREATE but by INSERT * INTO (so I do not specify the columns at creation), the UPDATE does not involve all the rows but only specified rows (so I can not add a column with simply a default value), etc. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Cornelius19
Starting Member
30 Posts |
Posted - 2008-12-09 : 17:19:19
|
| Thanks, that works fine!Cornelius |
 |
|
|
|
|
|