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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update a column help

Author  Topic 

ramotswa
Starting Member

6 Posts

Posted - 2009-01-09 : 09:32:39
Hello,

Another easy one.

Real simple column update, but I'm getting a "Operation must use an updateable query"

There shouldnt be any permission issues. Here is what ive got so far:

UPDATE [table1]
SET[col1] =
(Select table2.[col2] from table2 where [table1].tabID = table2.tabID);

Also, another question... if a table name has spaces in it do I need to use []'s?

Thanks
ramo

raky
Aged Yak Warrior

767 Posts

Posted - 2009-01-09 : 09:38:22
update t1
set t1.col1 = t2.col2
from table1 t1
inner join table2 t2 on t2.tabID= t1.tabID

and u can create table with a name containing spaces if and only if they are enclosed in []
Go to Top of Page

ramotswa
Starting Member

6 Posts

Posted - 2009-01-09 : 09:46:36
So here is what im doing...

UPDATE t1
SET t1.[column name with spaces] = t2.[more spaces]
from [table name with spaces] t1
inner join appraisers t2 on t2.appraiserID = t1.appraiserID;


and you can have spaces in table names and column names, if created in access.. (who thought of that stupid trick then!?)

thanks

Ramo
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-09 : 09:52:55
quote:
Originally posted by ramotswa

So here is what im doing...

UPDATE t1
SET t1.[column name with spaces] = t2.[more spaces]
from [table name with spaces] t1
inner join appraisers t2 on t2.appraiserID = t1.appraiserID;


and you can have spaces in table names and column names, if created in access.. (who thought of that stupid trick then!?)

thanks

Ramo


[] escapes characters like space,\,@,... which are other wise used by sql server to denote various other things
Go to Top of Page
   

- Advertisement -