March 12, 2018 at 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
March 12, 2018 at 2:23 pm
Krasavita - Monday, March 12, 2018 2:12 PMHello 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 errorThank 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).
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 12, 2018 at 3:52 pm
Makes me think the OP is thinking in terms of Oracle, which can do that...
March 14, 2018 at 12:32 pm
Or Access
March 14, 2018 at 1:29 pm
Krasavita - Monday, March 12, 2018 2:12 PMHello 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 errorThank 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)
March 14, 2018 at 2:32 pm
Joe Torre - Wednesday, March 14, 2018 12:32 PMOr Access
Eeeeeeuuuwwww... Joe said a bad word!
March 15, 2018 at 6:23 am
pietlinden - Wednesday, March 14, 2018 2:32 PMJoe Torre - Wednesday, March 14, 2018 12:32 PMOr AccessEeeeeeuuuwwww... 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