473,324 Members | 2,002 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,324 software developers and data experts.

How to pass a parameter to a view?

Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito
Jul 20 '05 #1
3 78575

"Benito" <be*******@juno.com> wrote in message
news:5c**************************@posting.google.c om...
Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito


Views cannot take parameters, but if you are using MSSQL 2000, then a
table-valued UDF is one solution:

create function dbo.MyFunc (@parm int)
returns table
as
return (
select col1, col2
from dbo.MyTable
where idcol > @parm
)

select col1, col2 from dbo.MyFunc(5)

There are examples in Books Online. If you have an earlier version of MSSQL,
then you'll have to use a stored procedure.

Simon
Jul 20 '05 #2
>> Is there an easy way that I could pass a filter (variable) unto a
view
via stored procedures? <<

VIEWs are virtual tables; they do not have parameters. Stored
procedures do take parameters and can return a resultset.
Jul 20 '05 #3
Simon,

Thanks for the suggestion. I am using MSSQL 2000. When creating a new
view at Enterprise Manager, I don't see the function I created at the
function tab of the Add Table Dialog Box. What I am trying to do is
store the filter in the function in the form of a variable then link
it to an existing view. Is this possible?

Benito

"Simon Hayes" <sq*@hayes.ch> wrote in message news:<3f********@news.bluewin.ch>...
"Benito" <be*******@juno.com> wrote in message
news:5c**************************@posting.google.c om...
Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito


Views cannot take parameters, but if you are using MSSQL 2000, then a
table-valued UDF is one solution:

create function dbo.MyFunc (@parm int)
returns table
as
return (
select col1, col2
from dbo.MyTable
where idcol > @parm
)

select col1, col2 from dbo.MyFunc(5)

There are examples in Books Online. If you have an earlier version of MSSQL,
then you'll have to 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: Tony Johansson | last post by:
Hello! I use method forName and newInstance in class Class like this instance = (GameFactory)(Class.forName(name).newInstance() ); Now to my question: Assume that name is GameFactory then I...
4
by: dyw55a | last post by:
I have 2 webform in vb.NET application. On Webform1, I have one text box1 and one button. on Webform2, I have one text box . I need transfer the value of textbox 1 in webform1 to textbox2 in...
1
by: Ray | last post by:
Dear all, How to pass parameter from vb.net to Crystal Report? I'm now using ReportDocument and CrystalReportViewer. However, I don't know how to pass a parameter to the report and print the...
1
by: jindo | last post by:
Hi There! I must stresstest webservices. So I used parameter Like this 'http://aaa.bbb.ccc/services/BoardFD.asmx?op=showTable&IDno=96&tab=900'. but the parameters are not passed. how to pass...
4
by: Chakravarti Mukesh | last post by:
Hi I want to call an application and also need to pass some parameter for it. I use System.Diagnostics.Process.Start("application_path") and it runs perfectly. But when I pass paramenter like...
1
by: Tarlanim | last post by:
Hi, i'm looking for a way to pass parameter from a HTML-File to a XML-File. In HTML-File i have a reference to XML-File and i want to use the parametre from the HTML-File in XML-File (Parameter...
0
by: Ed Dror | last post by:
Hi there, I'm using Visual studio 2005 pro and I want to pass parameter from datagrid selected cell to textbox I have Select button in my datagrid I wrote this Protected Sub...
15
vinvik
by: vinvik | last post by:
hi am calling one exe from java script using window.open.. now i need to pass parameter to that exe.. and that exe accepts the parameter from command line using(variable=command$).. now how i...
3
by: wingsganesh | last post by:
Hi Buddy, see my small example, Public Sub myPaint(ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.DrawString(" MichaelAyvazyan", Font, New SolidBrush(Color.Beige), 100, 100) ...
1
by: 2desperate2usedesperate | last post by:
ERROR: You do not have SELECT privileges on sys.V_$PARAMETER view. This process cannot proceed. Hello, I am using ORACLE 10g Standard Edition and I am trying to configure the Oracle Designer for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.