Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Syntax Error submitting query with coldfusion

I am getting this error and cannot find where my syntax is messed up can anyone please help me with what I am overlooking!

    [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the
    keyword 'Transaction'. 



<cfquery datasource="Titlesbymail" name="InsertEntry" result="transactionResult">
 INSERT INTO dbo.Transaction (Type, OwnerType)
 VALUES (
    <cfqueryparam value='NonLeased' cfsqltype='cf_sql_varchar' />
   , <cfqueryparam value='Owner' cfsqltype='cf_sql_varchar' />
 )
</cfquery>

My database looks like this :
enter image description here

The ID should be set up to automatically increment by 1 and the date time should automatically know it based on the getdate() function. So I am very unsure how I am making an error here.

like image 753
Vicki Avatar asked Dec 19 '22 04:12

Vicki


1 Answers

It looks like you have named your table using a SQL reserved word; Transaction. I would not recommend that as you may run into issues (like you have now).

However, it can be done. Try this and see if it works:

INSERT INTO [dbo].[Transaction] (Type, OwnerType)
VALUES (
   <cfqueryparam value='NonLeased' cfsqltype='cf_sql_varchar' />
  , <cfqueryparam value='Owner' cfsqltype='cf_sql_varchar' />
)

List of SQL Server reserved keywords: Reserved Keywords (Transact-SQL)

like image 138
Miguel-F Avatar answered Jan 12 '23 23:01

Miguel-F