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 2000 Forums
 Transact-SQL (2000)
 Inverting and inserting column values!

Author  Topic 

mibheenick
Starting Member

12 Posts

Posted - 2004-10-21 : 06:50:17
hi evryone,

Suppose i have two colums (SELECT(S) and TEST(T)) which are of type Char(1) in a table. These columns can only take values 'O' or 'N'.

i want to copy the inverse of one column in the other one. This may simplify wat i want to do...

Record#(S,T) Record#(S,T)
Record1(N,N) Record1(O,N)
Record2(N,O) Record2(N,O)
Record3(N,O) Record3(N,O)
Record4(N,N) Record4(O,N)
Record5(O,O) Record5(N,O)

In the above, I have overwritten column SELECT(S) with the inverse of the data in column TEST(T)

Thanx for helping

morleyhill
Starting Member

19 Posts

Posted - 2004-10-21 : 07:02:15
Hi

If I understand correctly, I think this will do the job-

update <<Table Name>>
set [Select] = case [Test]
when 'O' then 'N'
when 'N' then 'O'
end

Go to Top of Page
   

- Advertisement -