Friday, February 24, 2012

Include "/" in select statement

I wanted to create something like this:
Select (FirstItem + "/" + SecondItem) AS Item

but I get error. Is there anything wrong with this code?

P.S. I'm using mssql 2000

Hi,

in case FirstItem and SecondItem field are varchar type themselves, just replace double quotes ("/") with single quotes ('/')

e.g Select (FirstItem +'/' + SecondItem) AS Item

|||

Adding tojoteke's solution, if the columns are not of same datatype, you would do a CONVERT.

SELECT CONVERT(varchar(50),FirstItem ) +'/' + CONVERT(varchar(50),secondItem) AS Item

No comments:

Post a Comment