![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I am new to SQL Server 2000, and trying to learn it. I have a small practice table with 5 records. One field is called "fldcustomerID" in which the customer records are numbered 1,2,3,4,5. OPEN TABLE Using Enterprise Manager when I right click the TABLE to open the table as a query (using the graphical query thing) and put a "?" in the criteria box of "fldcustomerID" I get this: SELECT *, fldCustomerID AS Expr1 FROM tblCustomer WHERE (fldCustomerID = ?) The above pops us a dialog into which I type the customer ID I want and it works fine. NEW VIEW If I try the same thing by creating a VIEW when I type a "?" into the criteria box of the query designer I am presented with a message: "'Parameters' cannot be used in this query type." The SQL the designer creates is: SELECT dbo.tblCustomer.*, fldCustomerID AS Expr1 FROM dbo.tblCustomer WHERE (fldCustomerID = ?) When I run this it works just like the first query, and works fine. Why do I get the error message? Why does the query work? Thank you. |
#3
| |||
| |||
|
|
SQL Server doesn't support parameterized views. That's basically what the error is telling you. You can have parameters for SQL statements (like the query), stored procedures or you can use table valued parameterized user defined functions. But you can't use parameters in views. -Sue On Wed, 14 Sep 2005 09:00:14 -0700, kvr901 kvr901 (AT) discussions (DOT) microsoft.com> wrote: Hello, I am new to SQL Server 2000, and trying to learn it. I have a small practice table with 5 records. One field is called "fldcustomerID" in which the customer records are numbered 1,2,3,4,5. OPEN TABLE Using Enterprise Manager when I right click the TABLE to open the table as a query (using the graphical query thing) and put a "?" in the criteria box of "fldcustomerID" I get this: SELECT *, fldCustomerID AS Expr1 FROM tblCustomer WHERE (fldCustomerID = ?) The above pops us a dialog into which I type the customer ID I want and it works fine. NEW VIEW If I try the same thing by creating a VIEW when I type a "?" into the criteria box of the query designer I am presented with a message: "'Parameters' cannot be used in this query type." The SQL the designer creates is: SELECT dbo.tblCustomer.*, fldCustomerID AS Expr1 FROM dbo.tblCustomer WHERE (fldCustomerID = ?) When I run this it works just like the first query, and works fine. Why do I get the error message? Why does the query work? Thank you. |
#4
| |||
| |||
|
|
Thank you for your reply. One related question.... Below I wrote that I get an error stating that Parameters are not available, but it does work. It pops up a dialog, I type in a parameter, and get what I am looking for. When constructing the view it gives me the error, but it works later without error messages. Why? "Sue Hoegemeier" wrote: SQL Server doesn't support parameterized views. That's basically what the error is telling you. You can have parameters for SQL statements (like the query), stored procedures or you can use table valued parameterized user defined functions. But you can't use parameters in views. -Sue On Wed, 14 Sep 2005 09:00:14 -0700, kvr901 kvr901 (AT) discussions (DOT) microsoft.com> wrote: Hello, I am new to SQL Server 2000, and trying to learn it. I have a small practice table with 5 records. One field is called "fldcustomerID" in which the customer records are numbered 1,2,3,4,5. OPEN TABLE Using Enterprise Manager when I right click the TABLE to open the table as a query (using the graphical query thing) and put a "?" in the criteria box of "fldcustomerID" I get this: SELECT *, fldCustomerID AS Expr1 FROM tblCustomer WHERE (fldCustomerID = ?) The above pops us a dialog into which I type the customer ID I want and it works fine. NEW VIEW If I try the same thing by creating a VIEW when I type a "?" into the criteria box of the query designer I am presented with a message: "'Parameters' cannot be used in this query type." The SQL the designer creates is: SELECT dbo.tblCustomer.*, fldCustomerID AS Expr1 FROM dbo.tblCustomer WHERE (fldCustomerID = ?) When I run this it works just like the first query, and works fine. Why do I get the error message? Why does the query work? Thank you. |
![]() |
| Thread Tools | |
| Display Modes | |
| |