CFF KB - Carrz-Fox-Fire Promotions Knowledge Base

CFF KB is all about 1 thing: The Sharing of Knowledge and the Power we gain from it.
  • Breadrumbs:
  • Microsoft OLE DB Provider for SQL Server error '80040e14' Must declare the scalar variable

  • CFF Knowledge Base - Share With Facebook CFF Knowledge Base - Share on Twitter CFF Knowledge Base - Share on Reddit CFF Knowledge Base - Share on Digg It CFF Knowledge Base - Share on Stumble Upon It CFF Knowledge Base - Share on Delicious
    Share With Friends (Updated 6-8-2010)
  • Article ID:
    6264
  • Date Created
    Sunday, February 5, 2023
  • Last Updated
    Sunday, February 5, 2023
  • This Article Has been Viewed
    645 times
  • Short Desc
    Must declare the scalar variable "@P1GROUP" happens when you have a Column Name that is not listed in Statement.
  • Details
    When editing your SQL Script, you might misname your column or, in this case, move the Question Mark against another object in the statement.
  • Recreate Issue
    In this case, I moved the '?' against the [Group] in [Group by].

     
    Select Col1, Col2 from Table1 where Col3=?Group By Col1, Col2, Col3


    As you can see in the above Select Statement, the ?Group is against each other, causing this to become a single Variable in the Statement.
  • Resolve Issue
    To resolve this issue, place a space between your Variable and the Group By.

     
    Select Col1, Col2 from Table1 where Col3=? Group By Col1, Col2, Col3