0

Trying to do something like this:

select 'Setup for Car ' + CAST(varchar(50), @CarID) + ' for user ' + CAST(varchar(5), @UserID)

doesn't work, not sure what the syntax would be then for T-SQL. I've hunted around, have not found it yet.

2 Answers 2

2

You can user either of these:

select 'Setup for Car ' + Convert(varchar(50), @CarID) + ' for user ' + Convert(varchar(5), @UserID)

OR

select 'Setup for Car ' + CAST(@CarID as varchar(50)) + ' for user ' + CAST(@UserID as varchar(5))
Sign up to request clarification or add additional context in comments.

1 Comment

You can use either of of them, you just have to get the parameters in the correct location. :)
1

You are using CAST wrong. It should be

CAST(@Variable AS WhatYouAreCastingTo)

Here is a fiddle showing this

Remember, MSDN is your friend :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.