Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with joining a varchar to a smallint to form TCP/IP address 2

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX

declare @server varchar(255), @device smallint

set @device = 10
set @server = '192.168.0' + @device

Keep geting the error: syntax error converting the varchar value '192.16.0.' to a column of data type smallint.

I need to form this: 192.168.0.10 with the two different data types.

Thank you.
 
try this:

Code:
set @device = 10
set @server = '198.168.0' + '.' + convert(varchar(5), @device)

select @server

hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
Are you sleeping on the job over there Denis?

Sheesh :p

In your defense, it wasn't included in the original post (where I copied from)

Ignorance of certain subjects is a great part of wisdom
 
Them's just jokes. I know you wouldn't sleep when there is code to be written :)

Good Luck with the views!

Alex


Ignorance of certain subjects is a great part of wisdom
 
That works great. Thanks to SQLDenis and AlexCuse for the valuable information. Sorry about the missing (.) Have a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top