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.
| Author |
Topic |
|
asyncd
Starting Member
1 Post |
Posted - 2007-05-10 : 02:02:19
|
| Hi,I am pretty new with SQL and was dabbling in a test database that is linked with a software application.I made a change to a table - Lets call this (Table1).Table1 has a multiple columns.Column1 is defined as numeric(9)Column2 is defined as varchar(20)In this case, I wanted to make all values in Column2 = Column1 that did not have a value defined so I ran the following query:update Table1 set Column2 = Column1 where Column2 = ''This took effect but the particular software application doesn't recognize these values because they are the wrong data type.How can I convert all data in a column to varchar(20) if it is another data type (i.e. in this case numeric(9))?I've tried in Enterprise manager to redesign the table and adjusted the length to 21 and then back and saved it but this did not work. I was looking at Convert and Cast functions but don't know how to write one to accomplish what I need to do here.Half of the data in Column2 is varchar(20) and half is numeric(9).I want all to be varchar(20).Thanks,asyncd |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-10 : 02:07:01
|
"This took effect but the particular software application doesn't recognize these values because they are the wrong data type."I don't know what it implies. Did your UPDATE statement run successfully?You can try:update Table1 set Column2 = cast(Column1 as varchar(20)) where Column2 = '' "Half of the data in Column2 is varchar(20) and half is numeric(9)."I am stumped! How the half data can be varchar and other half numeric? How you deduced that?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|