Error trying to execute sql from inside SQL CLR
sqlclr
Solution
I needed to add DataAccess = DataAccess.Read to the function attribute in order to do that.
Problem
I have the following code: ``` [SqlFunction(DataAccess = DataAccessKind.Read, SystemDataAccess = SystemDataAccessKind.Read)] public static int GetInt() { int retValue = 0; using (SqlConnection conn = new SqlConnection("context connection = true")) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select MyInt from SomeTable"; object timeOut = cmd.ExecuteReader(); // <- error happen here } return retValue; } ``` I get the following exception in ``` cmd.ExecuteReader(); ``` {"This statement has attempted to access data whose access is restricted by the assembly."}