Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:43:21+00:00 2026-05-27T18:43:21+00:00

I have the following query that’s returning the error: Incorrect syntax near the keyword

  • 0

I have the following query that’s returning the error: “Incorrect syntax near the keyword ‘VIEW’.” I’ve tried to find any reference of this instance online and in SO. If I overlooked a solution or if anyone has any suggestions I’d greatly appreciate it.

Query:

    <cfquery datasource="#mydatasource#">
    CREATE VIEW #arguments.bulkRow.request_by#_uploader_features_view
    (
        feature_products_id
        , feature_text
        , feature_priority
    )
    AS
    SELECT
        a1.tbl_products__products_id AS feature_products_id,
        a1.tbl_productfeature__feature_text__1 AS feature_text,
        1 AS feature_priority
    FROM bulk_product_upload a1
    WHERE processed = 0
        AND request_by = <cfqueryparam value="#arguments.bulkRow.request_by#" cfsqltype="cf_sql_varchar">
        AND LEN( a1.tbl_productfeature__feature_text__1 ) > 1

    UNION

    SELECT
        a1.tbl_products__products_id AS feature_products_id,
        a1.tbl_productfeature__feature_text__2 AS feature_text,
        2 AS feature_priority
    FROM bulk_product_upload a1
    WHERE processed = 0
        AND request_by = <cfqueryparam value="#arguments.bulkRow.request_by#" cfsqltype="cf_sql_varchar">
        AND LEN(a1.tbl_productfeature__feature_text__2) > 1   

    ...

    UNION

    SELECT
        a1.tbl_products__products_id AS feature_products_id,
        a1.tbl_productfeature__feature_text__20 AS feature_text,
        2 AS feature_priority
    FROM bulk_product_upload a1
    WHERE processed = 0
        AND request_by = <cfqueryparam value="#arguments.bulkRow.request_by#" cfsqltype="cf_sql_varchar">
        AND LEN(a1.tbl_productfeature__feature_text__20) > 1
</cfquery>

This is an abbreviated form of the query but it should get you started and show the basic layout.

Thanks in advance,

JP

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:43:21+00:00Added an answer on May 27, 2026 at 6:43 pm

    I ran some testing against my own SQL Server and it appears that parameterized queries cause problems when creating views. Removing the CFQUERYPARAM tags should correct the issue. Using CFQUERYPARAM with a standard select statement is a best practice, but in this case you’re passing in SQL that will be executed every time the view is accessed, so the parameterization isn’t able to get passed through into the view.

    Here are a couple of examples using the same concept, but tables from one of my own databases.

    The following produces the Incorrect syntax near the keyword 'view' error:

    <cfset id="x" />
    <cfquery>
        create view #id#_view as
        select * from AdminUser
        where admID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#id#" />
    </cfquery>
    

    The following works fine:

    <cfset id="y" />
    <cfquery>
        create view #id#_view as
        select * from AdminUser
        where admID = '#id#'
    </cfquery>
    

    If anyone is able to locate a SQL Server reference which explains this in detail, feel free to edit this answer with a link.

    I would also note that depending on the value of the ID, you might consider wrapping the view name with brackets. If the ID begins with a number the statement will fail as-is, but putting that into a bracketed statement will cover those situations (just be sure to use the bracket notation when querying the view as well). Example: create view [#id#_view]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query with join table that works great: @eventsmy = Event.find(
I have the following query that runs in my Oracle database and I want
I have the following query that retrieve the number of users per country; SELECT
I have the following Sql Query that returns the type of results that I
Let say that we have the following query: SELECT DISTINCT COUNT(`users_id`) FROM `users_table`; this
I have the following query of linq to entities. The problem is that it
I have the following code and got myself confused: I have a query that
Lets suppose that I have the following simple query var q = from p
The following query will display all Dewey Decimal numbers that have been duplicated in
I have table that I insert data with following query (from c# code): INSERT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.