Using Crystal Reports version 13.0 in Visual Studio 2010.
Using the Command feature, all the fields needed are selected.
One of the fields is from a separate database on the same server.
SELECT r.ID, r.Revision,
u.FirstName + ' ' + u.LastName AS UpdateBy, r.UpdateDate,
s.Description AS Status, r.StatusID, r.Comments,
c.Notes
FROM Repel r
INNER JOIN Status s ON r.StatusID = s.id
INNER JOIN Conditions c ON c.SOCID = r.ID
LEFT OUTER JOIN [Admin].[dbo].[Users] u ON u.ID = r.UpdateBy
WHERE r.ID = {?item}
Using the database expert, both databases are connected but the command itself is on the main datasource.
The datasource with the tables Repel, Status, and Conditions.
It can NOT find the table Users.
The path is fully qualified so how can I get the report to see this table?
I know I could create a view in sql server itself and connect to that but there is a change that needs to be made to 30+ reports.
Thanks!!
EDIT
I tried to create a view in the main database only to use one datasource.
Then changed the line...
LEFT OUTER JOIN vUsers u ON u.ID = r.UpdateBy
Now I get the error:
This field name is not known.
Final EDIT
Doing more testing, I removed all database connections and fields from the report.
The unknown field name still appeared.
So, I removed everything from the report - still had the error.
Copied the text fields to a brand new report and added the database and command.
The error is now gone and the report is working.
Very strange.
Related
tell me how to make a user access to data access,
There is a table with dialogs, and you need to build a query so that another user cannot see this data if he does not have access to this dialog.
I tried to do it but it didn't work
SELECT *
FROM NameDS INNER JOIN
DialogueListDS ON NameDS.UserID = DialogueListDS.UserID INNER JOIN
MessegesListDS ON DialogueListDS.DialogueID = MessegesListDS.DialogueID
WHERE NameDS.UserID = '2B3F7596-DEC9-4CAF-A867-0127186CFC5C'
I had this code (which worked fine) in a calculated database that joined two SQL datasources:
select m.Email, m.SkuID,m.SkuName,l.Email,l.LastLogin,l.DocsAdded
from Licenses m
inner join ActivityReport l on l.Email = m.Email
Due to a bug in the reports API that provides incorrect information on LastLogin time information, I'm using the Users.get API and writing that information a new datasource (just the email of the user and their last login time). I want to join this with my other two data sources. Using the below code:
select m.Email, m.SkuID,m.SkuName,l.Email,l.DocsAdded,x.Email,x.LastLogin as LastLogin
from Licenses m
inner join ActivityReport l on l.Email = m.Email
inner join LastLogin x on x.Email = l.Email
I get the error:
License save batch failed: JDBC backend failure. More information: Failed to execute connection with error: Deadlock found when trying to get lock; try restarting transaction
I also get two errors that looks like this:
License save batch failed: Malformed SQL. More information: Error with SQL statement: Duplicate entry 'user#email.com' for key 'PRIMARY'.
What am I doing wrong?
I'm thinking you might need to add 'as' in your inner join unless you have already declared this in part of your code that was not posted.
from Licenses **as** m
inner join ActivityReport **as** l on l.Email = m.Email
inner join LastLogin **as** x on x.Email = l.Email
The second error is saying that you have more than one entry that your trying to join on. So you might consider trying to join on something that has unique entries to ensure you don't have duplicates in your join.
There is no issue in your query , query is right but this is deadlock issue ,So when many threads are running on server ,for example:
Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. So In case of deadlock, system automatically cancelled less expensive query.
If you try after sometime there will be no issue and therefore no error prompt.
I'm having issues where I'm unable to update any fields in my form.
I'll get "This recordset is not updatable" when I try to modify some fields.
I had to working when I inner joined 2 tables on my Form's Record Source.
SELECT dbo_Menzits.*, dbo_CCC_Job.*
FROM dbo_Menzits
INNER JOIN dbo_CCC_Job ON dbo_Menzits.MenzitID = dbo_CCC_Job.ExternalId
However when i try to join another table it won't allow me to update the recordset (as shown below). I know Access has some rules that needs to be followed as specified Here but I'm unable to understand some of the rules.
All my tables are linked tables and they all have primary keys.
This is how i joined it:
SELECT dbo_Menzits.*, dbo_CCC_Job.*, dbo_jms_JobDetails.*
FROM (dbo_Menzits
INNER JOIN dbo_jms_JobDetails ON dbo_Menzits.MenzitID = dbo_jms_JobDetails.MenzitID)
INNER JOIN dbo_CCC_Job ON dbo_Menzits.MenzitID = dbo_CCC_Job.ExternalId
I am looking to do a basic report and in my database, I have items in my main table representing hardware, software applications etc with a many to many relationship to the platform it belongs to.
In the event that a record has multiple platforms, I'd like it listen in a column separated by commas
Example of database layout
So Essentially I'd like to structure my query roughly as follows.
SELECT cat.CategoryName, sub.SubCategoryName, cur.Model, cur.Version, cur.Vendor, -- >pla.PlatformName, <--
cur.AvailableDate, cur.EndOfProduction, cur.EndOfSupport, dep.DepartmentName,
emp.FirstName + ' ' +emp.LastName AS 'Tech Owner', emp2.FirstName +' ' + emp2.LastName AS 'Tech Contact',
cur.NumOfDevices, cur.UpgradeDuration, cur.FiscalConsideration
FROM
dbo.Currency Cur
INNER JOIN dbo.SubCategory sub
ON cur.SubCategoryId = sub.SubCategoryId
INNER JOIN dbo.Category cat
ON sub.CategoryId = cat.CategoryId
INNER JOIN dbo.Employee emp
ON cur.OwnerId = emp.EmployeeId
INNER JOIN dbo.Employee emp2
ON cur.ContactId= emp2.EmployeeId
INNER JOIN dbo.Department dep
ON cur.PortfolioOwnerId = dep.DepartmentId
LEFT JOIN dbo.Currency_Dependency cd
ON cur.CurrencyId = cd.CurrencyId
LEFT JOIN dbo.Currency_Affected ca
ON cur.CurrencyId = ca.CurrencyId
LEFT JOIN dbo.Currency_Platform cpla
ON cur.CurrencyId = cpla.CurrencyId
Left JOIN dbo.Platform pla
ON cpla.PlatformId = pla.PlatformId
GO
So where I have platform name in that query, I would like to structure it as that list separated by commas, but I have no idea how I would go about that. Would one of you be able to guide me on the right path should there be one? Id like to start with being able to do so through a basic SQL query if there is such a way. Ultimately I'd like to build a report through SSRS (using SSDT in Visual Studio 2015) through a parameter or a filter but I can look into that a bit more as I'm just learning it and am doing my reading on it.
Thank you so much in advance
You can concatenate the platforms into a comma-separated string either in the SQL or in SSRS.
There are many articles already on how to do it in the SQL, just search for "For XML Path".
To do it in SSRS you can use a combination of LookupSet and Join.
=Join(LookupSet(Fields!EmployeeId.Value, Fields!EmployeeId.Value, Fields!PlatformName.Value, "DataSet1"), ", ")
The first two arguments would be the fields that you want to group by. The third one is the Platform value that you will be concatenating. The fourth argument is your dataset name.
If you need to make the list distinct, you'll need to add some custom code in the report to handle that. You would place that function inside the Join before the LookupSet.
Please bear with me as this may be a question without a possible answer, but I hope I describe it correctly..
I have a query which joins a number of tables and produces results, and here is the SQL:
SELECT
dbo.Property.PropertyPK,
dbo.Tenancy.TenancyPK,
dbo.Tenant.ContactFK,
dbo.Contacts.strTitle,
dbo.Contacts.strFirstName,
dbo.Contacts.strSurname
FROM dbo.Property
INNER JOIN dbo.Tenancy ON dbo.Property.PropertyPK = dbo.Tenancy.PropertyFK
INNER JOIN dbo.Tenant ON dbo.Tenancy.TenancyPK = dbo.Tenant.TenancyFK
INNER JOIN dbo.Contacts ON dbo.Tenant.ContactFK = dbo.Contacts.ContactPK
The main table is the Property table and I filter out one row by specifying a PropertyPK in my criteria..
My question is.. If the Tenant or Contact record does not exist and I run my query in SQL Management Studio of course I get a message saying there are no rows but can I determine at what stage the join has failed between two tables?
I can of course check this in management studio but I am trying to help the user on the application side to inform them of why there are no rows. My application is in VB and I will write that check if there are no rows and I cannot determine it in SQL..
Sorry for the question in advance..
Derek.. :)
Simply use a LEFT JOIN:
SELECT p.PropertyPK, ty.TenancyPK, t.ContactFK,
c.strTitle, c.strFirstName, c.strSurname
FROM dbo.Property p LEFT JOIN
dbo.Tenancy ty
ON p.PropertyPK = ty.PropertyFK LEFT JOIN
dbo.Tenant t
ON ty.TenancyPK = t.TenancyFK LEFT JOIN
dbo.Contacts c
ON t.ContactFK = c.ContactPK;
This will keep all rows in the Property table. You can then see which primary keys are NULL to see if there were matches in the other tables.
Note that the query is much easier to write and to read when you use table aliases.