473,899 Members | 4,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 20825

"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
2447
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 parameter): SELECT * FROM MyTableFunction(1)
2
4164
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 that would contain the Facility Code. When I run the query, the 'enter parameter value' box comes up twice, rquiring the parameter to be entered twice before the information is displayed. I hope I'm explaining this correctly. Can someone direct me...
2
1501
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 shows up in the datasheet view.
3
3135
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) look at results in datasheet view If I want to run the query again, I must d) click to close the datasheet view e) click on the query f) enter the parameter value
2
3164
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 a form which displays the information from the table. The end users have access to the form only - this is deliberate. I have created some queries, including parameter queries, to aid them which are accessible via buttons on the main form. ...
16
3174
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 parameter will not be changed - so don't worry. 2. It tells the implementor and the maintainer of this function that the parameter should not be changed inside the function. And it is for this reason that some people advocate that it is a good idea to...
0
4740
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 used in the calculations. At the moment we have a stored procedure that performs the calculations. This contains 22 queries. The remaining queries are stored as views (over 30). The problem we have is that one parameter is set in a view outside...
9
2703
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 and run it once you've made sure there is no harmful code. Currently we have several stored procedures which final result is a select with several joins that returns many
1
1717
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 that come from 3 different views, but all the views depend from the original view1. When I try to show the Report, it asks for the parameter Factory, but it does it 3 times (2 graphics + 1 data table). The user is getting angry because I don't know...
4
2276
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. The idea is when a user clicks the "View Suggesions" button, s/he will see an empty parameter box after clicking the button and before displaying the report. The user will have to type the "value" in the parameter box for example "January 2007". ...
0
9845
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11276
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10866
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8043
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5891
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6082
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.