• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 493
  • Last Modified:

table-valued function

Is there a way to run a table-valued function with a predefined user?  
0
takia1977
Asked:
takia1977
  • 4
  • 3
  • 2
3 Solutions
 
sbagireddiCommented:
You can create the function, right click ->Properties->Permissions-> add the user who needs permissions.
0
 
takia1977Author Commented:
This is the error message I am getting. I want the user to be able to run this without adding them the to table this function is using.  I was hopeing that I would be able to do this by predefining a user for this function to always execute as.

SELECT *
FROM func_GetUserInfo_FromLogin('tajohnson', DEFAULT)

Msg 7314, Level 16, State 1, Line 1
The OLE DB provider "SQLNCLI" for linked server "SCFDB01" does not contain the table ""Rosetta"."dbo"."RosettaStone"". The table either does not exist or the current user does not have permissions on that table.

0
 
sbagireddiCommented:
Looks like you will need to give permissions to the user for the table.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that functions must be CLR function?
note: functions must be called, AFAIK, with their schema perfix?



SELECT *
FROM dbo.func_GetUserInfo_FromLogin('tajohnson', DEFAULT)

Open in new window

0
 
takia1977Author Commented:
I am not sure what you mean by AFAIK?  I am pretty new to this whole thing.  As far as the schema prefix wouldnt that be the dbo part of the function name?  If I run the same select statement with my user account it works fine.  I think this is because I have permissions to the table.  
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
AFAIK = As Far As I Know :)

> If I run the same select statement with my user account it works fine.
you might have 2 "versions" (under different schema) of the same function name.
0
 
takia1977Author Commented:
Sorry, I just realized that I dont have the schema prefix in the original query that I sent.  But, I am still able to run the statement without the prefix.
0
 
takia1977Author Commented:
There is not another version.  Do you know of a way that I setup a defualt user for the Function to run as?  
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, you can specify the DEFAULT SCHEMA for the user:
http://msdn.microsoft.com/en-us/library/ms190387.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now