SQL Server - Converting varchar to int - Asked By David Morakong on 22-Feb-13 05:06 AM

Hi Guys is have the following code:
I'm trying to convert varchar to int and i get an error;

essentially i want to get the following result

@OutletID = 423,324

Can anyone help??


Declare @outlet varchar(1000),
        @outletID int


Select @outlet = '423,324'


Select '@Outlet',@outlet


Select @OutletID = Convert(int, @outlet, @OutletID)

Conversion failed when converting the varchar value '423,324' to data type int
Robbe Morris replied to David Morakong on 22-Feb-13 09:00 AM
int in sql server doesn't contain commas.  You'll have to strip them and any decimal points.