473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Parameter view

Hi everybody,

this view runs just fine but when I try to save it I have an error message:
ODBC error: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect of
syntax error. Where is the problem? I use questionmark because I need
unnamed parameter veiw.

select ProductID, NameOfProduct from dbo.Products where ProductID < ?

Thank you in advance,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
Croatia
Jul 20 '05 #1
3 20808

"Danilo Popović" <da************@trgostil.hr> wrote in message
news:bj**********@sunce.iskon.hr...
Hi everybody,

this view runs just fine but when I try to save it I have an error message: ODBC error: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect of
syntax error. Where is the problem? I use questionmark because I need
unnamed parameter veiw.

select ProductID, NameOfProduct from dbo.Products where ProductID < ?

Thank you in advance,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
Croatia


You can't use parameters with a view. If you have MSSQL2000, then you could
use a table-valued function:

create function dbo.GetProducts (@ProductID int)
returns table
as
return (select ProductID, NameOfProduct from dbo.Products where ProductID <
@ProductID)

select * from dbo.GetProducts(5)

Otherwise, you can use a stored procedure.

Simon
Jul 20 '05 #2
Thank you. ;-)

Reagards,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
"Simon Hayes" <sq*@hayes.ch> je napisao u poruci interesnoj
grupi:3f********@news.bluewin.ch...

"Danilo Popović" <da************@trgostil.hr> wrote in message
news:bj**********@sunce.iskon.hr...
Hi everybody,

this view runs just fine but when I try to save it I have an error message:
ODBC error: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect of
syntax error. Where is the problem? I use questionmark because I need
unnamed parameter veiw.

select ProductID, NameOfProduct from dbo.Products where ProductID < ?

Thank you in advance,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
Croatia


You can't use parameters with a view. If you have MSSQL2000, then you

could use a table-valued function:

create function dbo.GetProducts (@ProductID int)
returns table
as
return (select ProductID, NameOfProduct from dbo.Products where ProductID < @ProductID)

select * from dbo.GetProducts(5)

Otherwise, you can use a stored procedure.

Simon

Jul 20 '05 #3
And what Simon showed you is known as
"inline user-defined function". They give
you a functionality similar to parameterized
views. (Parameterized views are not
allowed in SQL Server 2000.)
--
Arun Marathe
Program Manager
SQL Server Query Processor
Microsoft Corporation

Disclaimers:
(1) This posting is provided "AS IS" with no warranties, and confers no
rights.
(2) Use of included script samples are subject to the terms specified at:
http://www.microsoft.com/info/cpyright.htm

"Danilo Popović" <da************@trgostil.hr> wrote in message
news:bj**********@sunce.iskon.hr...
Thank you. ;-)

Reagards,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
"Simon Hayes" <sq*@hayes.ch> je napisao u poruci interesnoj
grupi:3f********@news.bluewin.ch...

"Danilo Popović" <da************@trgostil.hr> wrote in message
news:bj**********@sunce.iskon.hr...
Hi everybody,

this view runs just fine but when I try to save it I have an error message:
ODBC error: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect of syntax error. Where is the problem? I use questionmark because I need
unnamed parameter veiw.

select ProductID, NameOfProduct from dbo.Products where ProductID < ?

Thank you in advance,

Danilo Popović, B. Sc.
Trgostil d.d. - IC
Toplička 16
49240 Donja Stubica
Croatia


You can't use parameters with a view. If you have MSSQL2000, then you

could
use a table-valued function:

create function dbo.GetProducts (@ProductID int)
returns table
as
return (select ProductID, NameOfProduct from dbo.Products where

ProductID <
@ProductID)

select * from dbo.GetProducts(5)

Otherwise, you can use a stored procedure.

Simon


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yarik | last post by:
Hello there! I am working with MS SQL Server 2000. I have a table function that takes an integer parameter and returns a table, and I can successfully use it like this (passing a literal as a...
2
by: Christine | last post by:
I am struggling to learn to use Access almost on my own, and have written a query that needs to have a parameter. The query I wrote includes in the Criteria of the design view, under the column...
2
by: Christine Brandel | last post by:
The code for the query I have written is: SELECT .,.,.,. FROM dbo_census WHERE (((.)=))); That code results in the parameter value request being made twice before the information I want...
3
by: thomas goodwin | last post by:
I have a query which asks for a parameter value to execute it. To see the results I have to: a) click on the query -- the "Enter Parameter Value" window pops up. b) enter the parameter value c)...
2
by: Simon Pleasants | last post by:
Am something of a newbie at this, so please bear with any stupid questions. I have created a database to track shipments that we import. The information is stored in a table and I have created...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
0
by: ngoodearl | last post by:
Hi, I have upsized an access db to a sequel 2000 db. The db is used to perform a series of calculations to get a result. The user inputs the required parameters into a form and the data entered is...
9
by: serge | last post by:
/* Subject: How to build a procedure that returns different numbers of columns as a result based on a parameter. You can copy/paste this whole post in SQL Query Analyzer or Management Studio...
1
by: kulungele | last post by:
Hi there, First of all, greetings from a newbie with Access. I have a View (let's call it view1) that asks for a parameter called "Factory?". I have a Report with 2 graphics and a data table...
4
meLady
by: meLady | last post by:
Hello, I have a report called employees' suggestions that displays all records in a employees' suggesions table, and I attached it in a click button called "View Suggestions Report". on a form. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.