If I have a table T with 4 rows & 2 columns A & B. A has
values 1,2,3,4. and B has 10,20,30,40. Write an Update SQL
query which can Swap the values of A & B for all records.
(Do not use a sub-query)

Answers were Sorted based on User's Feedback



If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30..

Answer / bunty

UPDATE T
SET A = B,B=A;

I am surprized but above query will fetch the desired
result.

Cheers,
Bunty

Is This Answer Correct ?    30 Yes 1 No

If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30..

Answer / avi007

select A as "B",B AS "A" from T;

Is This Answer Correct ?    1 Yes 2 No

If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30..

Answer / lova raju allumalla

update T set A=B,B=A where A in (select A from T);

Is This Answer Correct ?    1 Yes 2 No

If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30..

Answer / amit

UPDATE T
SET A = B, ENVDOR_NUMBERB = A

Is This Answer Correct ?    1 Yes 4 No

If I have a table T with 4 rows & 2 columns A & B. A has values 1,2,3,4. and B has 10,20,30..

Answer / preeti mishra

update T
set A:=A+B,
B:=A-B,
A:=A-B;

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL PLSQL Interview Questions

Explain the concept of normalization.

3 Answers  


Is record in oracle pl sql?

0 Answers  


I want to execute a piece of code before calling a procedure. How to achieve it?

1 Answers   Oracle,


What does truncate mean in sql?

0 Answers  


What is delete command in sql?

0 Answers  






Explain the methods used to protect source code of pl/sql.

0 Answers  


What is a trigger word?

0 Answers  


How to retrieve Duplicate Rows only in a Table? Suppose if a Table Name is "Education". It consists of multiple columns. Then if we insert rows into this table with duplicate records then how can we retrieve only duplicate records from that table?

28 Answers   Alps, Aricent, Bank Of America, Wipro,


Is ms sql traffic encrypted?

0 Answers  


how can we destroy the session, how can we unset the variable of a session? : Sql dba

0 Answers  


Which one of the following is a reason that an INSERT statement might cause an error instead of executing correctly? 1. The INSERT statement was attempting to insert a record into a view that was created from more than one table. 2. The INSERT statement was attempting to insert a record using a combination of constants and values from an existing table. 3. The INSERT statement was attempting to insert a record with a non-NULL value into a table that has that column defined as NULL. 4. The INSERT statement was attempting to insert a record into a table by selecting a record from that same table. 5. The INSERT statement was attempting to insert a record into a view rather than a table.

1 Answers   Sonata,


Do stored procedures prevent sql injection?

0 Answers  


Categories