Groups | Blog | Home
all groups > sql server programming > august 2006 >

sql server programming : back slash


troy
8/7/2006 11:16:37 PM
hello,

I need to add a blackslash to my select statement e.g. SELECT domain + '\' +
userid from LoginStuff but when I try and do it this gives me the following
error: Syntax error converting the varchar value '\' to a column of data
type int. Any idea?

thanks


Reg Besseling
8/7/2006 11:31:02 PM
Hi Troy

Try

select cast (domain as varchar(10)) + '/'+ cast(userid as varchar(10))
from LoginStuff

R.

[quoted text, click to view]
troy
8/8/2006 7:13:27 AM
both colums are varchar and all I'm trying to get a result that looks like
this: domainname\userid.

[quoted text, click to view]

Dan Guzman
8/8/2006 7:25:41 AM
[quoted text, click to view]

Although we have no DDL for the LoginStuff table, it seems that either your
domain or userid column is an int data type. Although a technique like the
one Reg suggested will avoid the error, it seems strange to me that you
would want to concatenate an integer value in this way. Perhaps your
intention was to specify a column like username instead of userid?

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Tracy McKibben
8/8/2006 9:18:43 AM
[quoted text, click to view]

I think you need to verify this, because the error message disagrees
with you...


--
Tracy McKibben
MCDBA
Dan Guzman
8/9/2006 12:00:00 AM
Can you post the table DDL? The only reason for the error that comes to
mind is that an int column is involved in the concatenation. You should not
get that message with varchar (assuming you are using Microsoft SQL Server).

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]

AddThis Social Bookmark Button