forum.venkateswarlu.net
      Register      Login
column values interchange

2 replies to this topic

Harikrishna Sikhakolli #1
Member
108 Points
Posted on 26 Mar 2012 12:26 PM IST Here I have one table like this
--Input
id surname name
1 sikhakolli harikrishna
2 gunja gopi
--output
id surname name
1 harikrishna sikhakolli
2 gopi gunja
Here both columns are of type varchar(15)
How can we acheive it. 
SQL Server     870 views     Reply to this topic
Laxman B #2
Member
26 Points
Replied on 29 Mar 2012 10:21 AM IST select id,name as surname,surname as name from tablename 
Reply to this topic
Harikrishna Sikhakolli #3
Member
108 Points
Replied on 05 Apr 2012 09:17 AM IST to get the the required out put use the below query
Query

update tablename
set surname=name,name=suranme

Here both columns must and should have same datatype.
 
Reply to this topic