Please help WHERE CLAUSE

  • use galactic

    where @customernumber = 263722

    exec stp_deliverystatus

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'where'

  • davidshephard (6/10/2010)


    use galactic

    where @customernumber = 263722

    exec stp_deliverystatus

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'where'

    Use galactic is to switch database context.

    In order to use the where clause, you need to also use a select, insert, delete, or update statement.

    The final piece of your code is to execute a stored procedure.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thanks let me try your idea..

  • Sounds to me like you are trying to execute a stored procedure with the "WHERE" part as your input parameter...

    exec stp_deliverystatus @customernumber = 263722

    Full syntax:

    USE [Galactic]

    GO

    DECLARE@return_value int

    EXEC@return_value = [dbo].[stp_deliverystatus]

    @customernumber = 263722

    SELECT'Return Value' = @return_value

    GO

    gsc_dba

  • Thank you sir,I have been working on this for three weeks,but I added the year parameter and get an error message:

    USE [Galactic]

    GO

    DECLARE @return_value int

    EXEC @return_value = [dbo].[stp_deliverystatus]

    @customernumber = 263722

    @year = 2005

    SELECT 'Return Value' = @return_value

    GO

    Msg 102, Level 15, State 1, Line 6

    Incorrect syntax near '@year'

  • Does the stp_deliverystatus stored proc take two parameters? If not, you can't just pass two parameters to it and expect that it'll work.

    I strongly suggest at this point that you pick up an intro to SQL type book and do some background reading, or look for a basic SQL tutorial on the net.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks my friend,it does take two parameters I will take that advise but would like to help hear since this would be a good learning tool..

  • davidshephard (6/11/2010)


    Thank you sir,I have been working on this for three weeks,but I added the year parameter and get an error message:

    USE [Galactic]

    GO

    DECLARE @return_value int

    EXEC @return_value = [dbo].[stp_deliverystatus]

    @customernumber = 263722

    @year = 2005

    SELECT 'Return Value' = @return_value

    GO

    Msg 102, Level 15, State 1, Line 6

    Incorrect syntax near '@year'

    I would also suggest taking the time to read Books Online, the SQL Server Help System, it would help you with the syntax of the various commands.

    As your stored procedure does accept two parameters, the problem is a missing comma:

    USE [Galactic]

    GO

    DECLARE @return_value int

    EXEC @return_value = [dbo].[stp_deliverystatus]

    @customernumber = 263722,

    @year = 2005

    SELECT 'Return Value' = @return_value

    GO

  • USE [Galactic]

    GO

    DECLARE @return_value int

    EXEC @return_value = [dbo].[stp_deliverystatus]

    @customernumber = 263722,

    @year = 2005

    SELECT 'Return Value' = @return_value

    GO

    You need to separate the parameters with a comma. Is this the Galactic database that come with Larrson's books?

  • Hi Lynn and all,thanks so much only took three weeks to get it to work.

    Thanks again all...

  • Yes from Larson's book..

  • davidshephard (6/11/2010)


    Yes from Larson's book..

    Do you mind sharing which book it is?

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • SQL SERVER 2005 Reporting Services Brian Larson

    ISBN139780072262391

    0072262397

  • Thanks

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • May I suggest that you start with an introductory T-SQL book rather. T-SQL Fundamentals (Itzik Ben-Gan) is a good option. worry about things like Reporting Services when you know how to write a SQL query.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 15 posts - 1 through 15 (of 21 total)

You must be logged in to reply to this topic. Login to reply