misdevelopment
asked on
SQL 2005 Parameterized Views ?????
I'm just looking at trying to create a view in SQL 2005 that pulls back data based upon a value.... i.e. :
SELECT request_item AS [Item Reference], request_by AS [Requested By], requested_on AS [When Requested]
FROM dbo.PCT_Active_Requests
where request_to = @in_site
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
Now, I know I can't use parameters in a View, so I'm guessing I need a function. Basically, the 'SITE' argument is calculated on what the user logs into windows as. Again, this is no problem when calling a stored procedure from a .net front end as the system.environment.usernam e is able to be passed as a parameter.
What I'm looking to do, I think....., is to be able to create a view which has a function as the argument for the WHERE statement, but the function needs to be able to know what the user is logged into windows as....we're not planning on using INTEGRATED SECURITY, but if we have to, then we have to....
I hope this makes some sort of sense?
Thanks,
JC
SELECT request_item AS [Item Reference], request_by AS [Requested By], requested_on AS [When Requested]
FROM dbo.PCT_Active_Requests
where request_to = @in_site
--------------------------
Now, I know I can't use parameters in a View, so I'm guessing I need a function. Basically, the 'SITE' argument is calculated on what the user logs into windows as. Again, this is no problem when calling a stored procedure from a .net front end as the system.environment.usernam
What I'm looking to do, I think....., is to be able to create a view which has a function as the argument for the WHERE statement, but the function needs to be able to know what the user is logged into windows as....we're not planning on using INTEGRATED SECURITY, but if we have to, then we have to....
I hope this makes some sort of sense?
Thanks,
JC
>Now, I know I can't use parameters in a View, so I'm guessing I need a function
correct
you are aware of the function user, system_user ...
correct
you are aware of the function user, system_user ...
ASKER
If we aren't using integrated security, how will this show me the windows username though?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The view / stored procedure is going to be databound to a dataview in a windows forms app...