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 |
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-06-17 : 09:02:50
|
| I have a nvarchar column and an int columnI tried thisselect distinct cast(name as int) from callsheet.dbo.product union allselect distinct id from callsheet.dbo.productbut I can't convert it because name is nvarchar |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-06-17 : 09:05:23
|
| select distinct name from callsheet.dbo.product union allselect distinct convert(varchar(20),id) from callsheet.dbo.productStrange values to union - maybeselect distinct name, id = convert(int,null) from callsheet.dbo.product union allselect distinct null, id from callsheet.dbo.product==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-06-17 : 09:50:40
|
| so the expected result should look like this ... name + number in one cell like this xxxxx + (1234567) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-17 : 09:52:37
|
select distinct cast(id as varchar(200)) + cast(name as varchar(200) from callsheet.dbo.product E 12°55'05.63"N 56°04'39.26" |
 |
|
|
kote_alex
Posting Yak Master
112 Posts |
Posted - 2009-06-17 : 09:58:53
|
quote: Originally posted by Peso select distinct cast(id as varchar(200)) + cast(name as varchar(200) from callsheet.dbo.product E 12°55'05.63"N 56°04'39.26"
thanks !!! it worked ! :D |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-06-17 : 09:59:38
|
| select name + ' + (' + convert(varchar(20),id) + ')' from callsheet.dbo.productI've taken out the distinct - put it back in if it is needed but it's best to remove it if the values are unique.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|