Closed pascalfriedrich closed 6 years ago
Does this SQL work if you directly execute it in SSMS?
Have you tried 123619
without quotes, i.e. INSERT INTO...VALUES ('LIEFERMAX', 123619, 'FVS_TRCK'...)
Yes, it does work in SSMS or similar. Yes, we tried it without quotes, but without success.
We are using SQL Server 2012, could that cause this issue? Because your supported FreeTDS Version is just up to 7.3
I think the problem is with your IF
statement:
IF NOT EXISTS (SELECT * FROM dbo.V_TUR_IMP WHERE toursno = '123619')
SQL server is attempting to convert 123619')
to an INT. Try removing the single quotes, or removing that IF statement entirely to see if the insert succeeds.
Yes, here's your problem: https://stackoverflow.com/questions/20105641/sql-if-not-exists-syntax-error
Hello,
when executing the following query
IF NOT EXISTS (SELECT * FROM dbo.V_TUR_IMP WHERE toursno = '123619') INSERT INTO dbo.V_TUR_IMP (system, toursno, ifid, DATLIEF, STATUS, kmstart, kmend, azeit, ezeit, abfahrtzeit, ankunftzeit, pausenzeit, CRD, CRUSER, CHD, CHUSER, FAHRER, BEIFAHRER, KFZ, HAENGER) VALUES ('LIEFERMAX', '123619', 'FVS_TRCK', CONVERT(datetime, '2018-07-25 00:00:00', 120), 1, 120555, 120617, '0603', '0553', '0603', '0553', 0, CONVERT(datetime, '2018-07-25 06:03:17', 120), 'LIEFERMAX', CONVERT(datetime, '2018-07-26 05:53:18', 120), 'LIEFERMAX', 521, 69, 20, -1);
the server responds with the following error message:
"Conversion failed when converting the varchar value '123619)' to data type int."
Why is there a bracket inside the number? Even if we try to write it like
Convert(int, 123123)
... very strange. We are clueless. Would be great if anyone could help us.Best regards