February 18, 2006 at 1:47 am
Hi Guys,
Does any one know if an argumant(s) can be passed to view in SQL 2000 like date or employee number etc...
I know for sure in Access we can have a input box for user to enter requested parameter.
Thanks n regards
Vikram
February 18, 2006 at 9:11 am
The parameter in a view is in the where clause.
select * from myView where SomeCol = 'SomeVal'
February 18, 2006 at 10:01 pm
Thanks Steve for the reply,
I was looking for a code like create view etc.... similar to what is used in create proc and then we write paramaters shich will be passed to proc.
If I can get some sample code with create view and how to pass a argument which will be use in select of that view.
Appreciate your time.
regards Vikram
February 20, 2006 at 11:09 am
I think you're going to need to use a function:
CREATE FUNCTION dbo.udf_ReturnEmployeeRecordByID(
@EmployeeID VARCHAR(12)
 
RETURNS @EMPLOYEE_ID TABLE(
EMPLOYEE_ID VARCHAR(12),
EMPLOYEE_NAME VARCHAR(100)
 
AS
BEGIN
INSERT INTO @EMPLOYEE_ID
SELECT AD.EMPLOYEEID, AD.PREFERRED_FIRST+' '+AD.PREFERRED_LAST EMPLOYEE_NAME_FULL
FROM DBO..MYTABLE AD
WHERE (
AD.EMPLOYEEID = @EmployeeID
)
RETURN
END
Syntax for retrieving records is:
SELECT * FROM DBO.udf_ReturnEmployeeRecordByID('1234)
HTH:
MM
February 21, 2006 at 12:06 am
Thanks Mark,
I am using function now but it is slow for latger records.
That's why I was looking to have this via view, I guess I am expecting too much from view .
regards Vikram
February 21, 2006 at 7:10 am
OYE!!
VIEWS CAN'T BE PARAMETERISED,
FOR THIS YOU HAVE TO CREATE A PROCEDURE.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply