trying to get some data from Account in MSCRM 8 onpremise
we have sql query something like this:
select distinct top 100 acc.accountid,acc.OwnerId, ..., acc.v_ownerid
from account acc
where acc.statecode = 0 and (1=0 or acc.accountid= xxxx)
When I Try to run this select from my C# code I am getting an error:
System.Data.SqlClient.SqlException: Invalid column name 'acc.v_ownerid'.
The field 'acc.v_ownerid' for 100% exists in DB
Please where can be the problem?
Petr
With MSCRM on-prem running SQL queries against the tables is unsupported.
Microsoft supports only two operations against an MSCRM SQL database:
SELECT
queries against the filtered views... eg FilteredAccount.In addition to providing the text values for lookups and option sets, the filtered views also enforce security at the database level.
You might want to refactor your SQL to use the FilteredAccount view and see how you make out with that.
Also, please note that the Account table is called AccountBase.
The database object named Account is actually a view (which it is also unspported to query, as it is not a Filtered view.)
The only supported way to query for Accounts in SQL is via the FilteredAccount view:
Well, the solution is to use this select
Select distinct top 100 acc.accountid,acc.OwnerId, ..., acc.v_ownerid from
X.dbo.account acc
where acc.statecode = 0 and (1=0 or acc.accountid= xxxx)
instead of:
select distinct top 100 acc.accountid,acc.OwnerId, ..., acc.v_ownerid
from account acc
where acc.statecode = 0 and (1=0 or acc.accountid= xxxx)
Then it returns all columns, do not know why, but it is working...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.