Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Creating Parameters

Author  Topic 

kopzen
Starting Member

34 Posts

Posted - 2008-07-15 : 05:46:03
Hi guys

This is my stored procedure:

ALTER procedure [dbo].[aidapr]
as
SELECT
Ipage,
Rhost,
Idevice,
Ifield,
Ivalue
from dbo.latest_data order by Rhost


And the link below is my data output

[url]http://img502.imageshack.us/img502/5079/mytablejl6.tif[/url]

Based on the above,
I want to create two parameters:

1. Rhost (Server Names): Grabs all values related to the chosen Server from all columns.
2. IPage (Components): Grabs all Component values related to the chosen Server

Please check my link


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-15 : 06:02:20
ALTER procedure [dbo].[aidapr]
(
@Rhost varchar(50)),
@IPage int
)
as
SELECT
Ipage,
Rhost,
Idevice,
Ifield,
Ivalue
from dbo.latest_data
where Rhost=@Rhost and Ipage=@Ipage
order by Rhost



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kopzen
Starting Member

34 Posts

Posted - 2008-07-15 : 06:06:08
I get the following error message:

Msg 1050, Level 15, State 1, Line 2
This syntax is only allowed for parameterized queries.
Msg 137, Level 15, State 2, Line 13
Must declare the scalar variable "@Rhost".
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-15 : 06:12:27
There is extra brace.

Try this

ALTER procedure [dbo].[aidapr]
(
@Rhost varchar(50),
@IPage int
)
as
SELECT
Ipage,
Rhost,
Idevice,
Ifield,
Ivalue
from dbo.latest_data
where Rhost=@Rhost and Ipage=@Ipage
order by Rhost



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kopzen
Starting Member

34 Posts

Posted - 2008-07-15 : 06:22:45
Another Error message:

Msg 201, Level 16, State 4, Procedure aidapr, Line 0
Procedure or Function 'aidapr' expects parameter '@Rhost', which was not supplied.

What does this mean?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-15 : 06:27:53
quote:
Originally posted by kopzen

Another Error message:

Msg 201, Level 16, State 4, Procedure aidapr, Line 0
Procedure or Function 'aidapr' expects parameter '@Rhost', which was not supplied.

What does this mean?


When you execute the procedure, you need to supply the value for the input parameters

EXEC aidapr 'somevalue',somenumber

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -