(that represents the number of the w
, and the year)i have a table that holds these 2 columns ("w
" , "year") as integers(i can't change it to string)
i want to return them as one result, but when i do this:
SELECT w
+ year AS [result w
]the result i get is the w
added to the year (since they both areintegers)
how do i get the result as an added string?
thanks!SELECT CONVERT(VARCHAR(2), w
) + CONVERT(CHAR(4), year) AS [result w
]<friedman30@.gmail.com> wrote in message
news:1146748724.890049.324700@.y43g2000cwc.googlegroups.com...
>i need to add 2 results from a query to get this string: 2.2006
> (that represents the number of the w
, and the year)> i have a table that holds these 2 columns ("w
" , "year") as integers> (i can't change it to string)
> i want to return them as one result, but when i do this:
> SELECT w
+ year AS [result w
]> the result i get is the w
added to the year (since they both are> integers)
> how do i get the result as an added string?
> thanks!
>|||declare @.w
intdeclare @.year int
declare @.string varchar(16)
set @.w
= 2set @.year = 2006
select @.string = cast(@.w
as varchar(2)) + '.' + cast (@.year aschar(4) )
print @.string|||thanks!
that really works
No comments:
Post a Comment