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
 General SQL Server Forums
 New to SQL Server Programming
 updating column from other col. values

Author  Topic 

lucifer
Starting Member

3 Posts

Posted - 2012-10-27 : 23:42:31
I have a varchar col. in which I want to enter the value of an int column, and other two varchar values.

something like:

update table
set Cust = intColumnVal + '-' + varColumnVal + ...;


where + isnt math op ofcourse, just string append.

thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-28 : 00:33:08
you need to cast it to varchar for append


update table
set Cust = cast(intColumnVal as varchar(10)) + '-' + varColumnVal + ...;


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2012-11-02 : 05:16:53
You can just do a SELECT

SELECT Cust = cast(intColumnVal as varchar(10)) + '-' + varColumnVal + ... FROM table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -