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 |
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-03-08 : 03:49:56
|
| Hi,I need to prefix a string while selecting a columnSelect ('username' + Col) as uname from MyTable.Tableabc123Outputusernameabcusername123I tried Select (uname = 'username' + Col) FROM MyTableHow should my query be. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 03:55:20
|
what is first row ? How do you define 1st row ? There isn't any first or last or nth row in database. The physical ordering of record has no meaning at all. KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-08 : 04:00:55
|
| SELECT 'UserName' + Col as uNameFROM MyTablePeter LarssonHelsingborg, Sweden |
 |
|
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-03-08 : 04:01:16
|
Sorry I modified my post.I got a workaround for my issue.quote: Originally posted by khtan what is first row ? How do you define 1st row ? There isn't any first or last or nth row in database. The physical ordering of record has no meaning at all. KH
|
 |
|
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-03-08 : 04:01:16
|
Sorry I modified my post.I got a workaround for my issue.quote: Originally posted by khtan what is first row ? How do you define 1st row ? There isn't any first or last or nth row in database. The physical ordering of record has no meaning at all. KH
|
 |
|
|
Babli
Yak Posting Veteran
53 Posts |
Posted - 2007-03-08 : 04:04:32
|
I need to cast my column.The reply from Peso worked great.Thanks a lotquote: Originally posted by Babli Sorry I modified my post.I got a workaround for my issue.quote: Originally posted by khtan what is first row ? How do you define 1st row ? There isn't any first or last or nth row in database. The physical ordering of record has no meaning at all. KH
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-08 : 04:07:31
|
| No need to cast if both 'abc' and '123' are valid data.Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-08 : 04:08:18
|
| But if you tricked us by posting invalid sample data, and you are only using numbers, this is the way to goSELECT 'UserName' + CAST(Col AS VARCHAR) as uNameFROM MyTablePeter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|