how to open view on inserting values

  • Hello I am trying create view, when I run it it will ask for values, I enter and it will search for data,here is my code I cant figured out what I am doing wrong, I get error
    incorrect syntax near keyword declare
    incorrect syntax near @pm_prd
    must declare scalar variable @pm_prd, I inserted error

    Thank you so much for your help

  • Krasavita - Monday, March 12, 2018 2:12 PM

    Hello I am trying create view, when I run it it will ask for values, I enter and it will search for data,here is my code I cant figured out what I am doing wrong, I get error
    incorrect syntax near keyword declare
    incorrect syntax near @pm_prd
    must declare scalar variable @pm_prd, I inserted error

    Thank you so much for your help

    Views don't take parameters. Take a look at table valued functions.
    And nothing in the SQL Server database engine runs like that ('asking for values'). You need some other tool to do that for you (eg, SSRS, a Windows app or a Web app).

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Makes me think the OP is thinking in terms of Oracle, which can do that...

  • Or Access

  • Krasavita - Monday, March 12, 2018 2:12 PM

    Hello I am trying create view, when I run it it will ask for values, I enter and it will search for data,here is my code I cant figured out what I am doing wrong, I get error
    incorrect syntax near keyword declare
    incorrect syntax near @pm_prd
    must declare scalar variable @pm_prd, I inserted error

    Thank you so much for your help

    Yeah, you can't get that functionality from SQL Server alone.  While both Oracle and MS Access can do that, SQL Server uses either stored procedures that can then work with parameters, or functions (preferably table-valued for performance) (also able to work with parameters).  You either EXECUTE a stored procedure or you SELECT from a table-valued function or include a scalar function in a SELECT statement.  Prompting for parameter values isn't something SQL Server does.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Joe Torre - Wednesday, March 14, 2018 12:32 PM

    Or Access

    Eeeeeeuuuwwww... Joe said a bad word!

  • pietlinden - Wednesday, March 14, 2018 2:32 PM

    Joe Torre - Wednesday, March 14, 2018 12:32 PM

    Or Access

    Eeeeeeuuuwwww... Joe said a bad word!

    Probably closer to reviled than inherently bad.   It's all a matter of use case.   Most people abuse it, and that's where the grief lies.   It's as much a tool as any other piece of software, but rarely gets the credit it deserves, or the proper usage.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

Viewing 7 posts - 1 through 6 (of 6 total)

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