Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conversion failed when converting the varchar value to int

I'm getting an error with what should be a simple query to insert data. I've done searching, but for the life of me, I cant figure out whats happening. Here's my SQL:

IF OBJECT_ID('settings') IS NOT NULL
DROP TABLE [settings]
CREATE TABLE [settings] (
    [id] [bigint] IDENTITY(1,1) NOT NULL PRIMARY KEY,   
    [tenant_id] [bigint] NOT NULL, 
    [name] [varchar](32) NOT NULL, 
    [value] [varchar](255) NOT NULL
)

INSERT INTO settings 
       (name, value, tenant_id)
       VALUES
       ('from_email' , '', 1),
       ('dash_rss', '', 1),
       ('theme', '', 1),
       ('version', '0.84', 1),
       ('iphone_theme', '', 1),
       ('enable_sandbox_number', 1, 1),
       ('twilio_endpoint', 'https://api.twilio.com/2008-08-01', 1);

And the error I get is: Conversion failed when converting the varchar value '0.84' to data type int.

Why is it trying to convert this to int when the column is varchar?

like image 320
Allen Avatar asked Oct 14 '22 22:10

Allen


1 Answers

I wonder if SQL Server is trying to outsmart you here. I noticed that your 'enable_sandbox_number' row includes an integer for the second parameter. Maybe SQL Server is converting to int because of that. Can you change 1 to '1' in that row?

like image 179
bobs Avatar answered Oct 18 '22 01:10

bobs