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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to concatenate a string to a int value

Author  Topic 

token
Posting Yak Master

133 Posts

Posted - 2007-03-05 : 14:14:58
I hope this is the correct place to ask this...

I would like to concatenate a String value to an Int value using an SQL statement. At the moment it reads like this:

SELECT 'website.com/shop/product.cfm?ProductID=' + Products.ProductID AS Product_URL

But unfortunately I am getting the error:
"Conversion failed when converting the varchar value 'website.com/shop/product.cfm?ProductID=' to data type int."

Any idea how to get around this at all just using an SQL query statement?

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-03-05 : 14:17:54
SELECT 'website.com/shop/product.cfm?ProductID=' + cast(Products.ProductID as varchar(10)) AS Product_URL

Go to Top of Page

token
Posting Yak Master

133 Posts

Posted - 2007-03-05 : 15:04:30
Wow, quick reply and it worked a treat! Thank you so much :-)
Go to Top of Page
   

- Advertisement -