How to swap the data of two columns in a table. both the
columns containing varchar values.

Answers were Sorted based on User's Feedback



How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / nilesh

UPdate temp
set col1=col2,
col2=col1

Is This Answer Correct ?    21 Yes 15 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / ami tkumar

Sorry for previous answer.

DECLARE @temp AS varchar(50)
UPDATE swapdata SET @temp=value2,value2=value1,value1=@temp

Is This Answer Correct ?    5 Yes 3 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / mysql

sorry guys, all ur answers are not working properly.
Try to answer in one sql statement.

Is This Answer Correct ?    2 Yes 1 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / dinesh

select menu from (select m_name as menu from m_master) a
union select m_name as menu from db2 .dbo.m_master

Is This Answer Correct ?    0 Yes 1 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / dinesh

select names from
(select full_name as names from table 1) a
union
select full_name as names from table 2

Is This Answer Correct ?    0 Yes 2 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / san

create table san(empid int,empname varchar(10))
insert into san values(1'san')
update san set empid=empname,empname=empid

Is This Answer Correct ?    0 Yes 3 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / sandeep rana

create table tmp_t
(
aa varchar2(50),
bb varchar2(50)
)


--insert into tmp_t values('1','5')


select * from tmp_t

update tmp_t set aa=bb , bb=aa

Is This Answer Correct ?    7 Yes 12 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / amit kumar

select Col1,col2 into newtable

Is This Answer Correct ?    0 Yes 5 No

How to swap the data of two columns in a table. both the columns containing varchar values...

Answer / m s aptil

update tab1 set name=name1,name1=name

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More SQL Server Interview Questions

When does the auto update index statistics feature in sql server turn itself on?q) what specific conditions database should meet, before you can bulk copy data into it using bcp?

0 Answers  


Where do you think the users names and passwords will be stored in sql server?

4 Answers   BirlaSoft,


Is truncate a dml command?

0 Answers  


Explain different types of self contained sub query?

0 Answers  


How secure is sql server database?

0 Answers  






What is apply operator in sql?

0 Answers  


Why it is recommended to avoid referencing a floating point column in the where clause?

0 Answers  


Can a stored procedure call itself or recursive stored procedure? How many levels sp nesting is possible?

0 Answers  


Explain what are various ways to enhance the ssrs report?

0 Answers  


How can a user-defined datatype be created?

0 Answers  


What are the restrictions that views have to follow? : SQL Server Architecture

0 Answers  


What is pessimistic concurrency?

0 Answers  


Categories