SQL syntax Error sending request with coldfusion

I am getting this error and cannot find where my syntax is messed up. Can anyone help me with what I am missing?

    [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 configured to auto 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 the mistake here.

+3


source to share


1 answer


It looks like you named your table using the SQL reserved word; Transaction

... I would not recommend this as you may run into problems (for example you have).

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)

+10


source







All Articles