Concatination
In SQL Server 2005 how can i concatinate a string with an Integer??
for example I have a table named Branch_Details in which there is a field named B_Code which is numeric, and when I use SELECT query I want it to be displayed in B001, B002, B003.........B00n format. How can i accompalish this??
# 1 Re: Concatination
You mean you want to take 1000 rows of one int column ,and turn them into 1 row of 1 column where the value is the string concat of all rows?
1
2
3
...
998
999
1000
->
"1, 2, 3, ..., 998, 999, 1000"
-
It's hard. I'd just do it in the client side code
cjard at 2007-11-9 13:45:18 >

# 4 Re: Concatination
erm.. more like that its trying to convert the 'B' into an int..
Try
select 'B' + CAST(123 AS VARCHAR)
Or use oracle. Its much less dumb with things like this.
cjard at 2007-11-9 13:48:23 >

# 5 Re: Concatination
erm.. more like that its trying to convert the 'B' into an int..
Try
select 'B' + CAST(123 AS VARCHAR)
Or use oracle. Its much less dumb with things like this.
Thanks it worked. In front of Oracle 9i. I consider SQL Server 2005 dull
# 7 Re: Concatination
OK now I want a slight change. My Query is like this.
SELECT 'B00' + CAST(B_Code AS VARCHAR) FROM Paramet
Where B_Code is a numeric
Now there is a slight problem. If the value of B_Code is in single digit then its OK but if its 2 digits lets say 17, then it will Display B0017 similarly if its 3 digits lets say 100, it will display B00100.
But I don't want it this way. I want it to be displayed in such a way that in first case it should display B017 and in 2nd case B100. How can I achieve this??
Thanks in Advance