Reputation: 9
I have this stored procedure here:
else if(substring(@SMS,1,1)='S')
begin
insert into WEB_POROSIA..SMS_SERVISI(IDTICKET, MBYLLUR) values(convert(int,substring(@SMS,2,len(@sms)-1)),1)
select @sms
end
What it does is: I send a SMS like this:
S 23 and in the database it saves the 23 value..
Now, it works like this but not if I add a letter before: i.e
S B21 it should insert B21 to the table...
How to modify it?
Upvotes: 0
Views: 9446
Reputation: 11599
values(convert(int,substring(@SMS,2,len(@sms)-1)),1)
^ Because you are converting it into int
You can convert
into varchar
if you to get B
values(convert(varchar,substring(@SMS,2,len(@sms)-1)),1)
(Assuming you will alter
the table and change the datetype
from int
to varchar
)
Upvotes: 2
Reputation: 411
You will need to remove the conversion to int:
insert into WEB_POROSIA..SMS_SERVISI(IDTICKET, MBYLLUR) values(substring(@SMS,2,len(@sms)-1),1)
You may also need to modify the type on the target column if that is also using int.
Upvotes: 0