In crystal I am trying to do a full outer join however the option is disabled (greyed out) in the database expert. Does anyone know why or how to get this to work so I can select it?
Related
I submitted a new join in Azure Data Lake and got CQO: Internal Error - Optimizer internal error when I use left join or outer join in my U-SQL script. I tried to use inner join instead of left join and also tried to use left join in COSMOS. Both cases are working fine. Can anyone tell me why left join doesn't work in Azure Data Lake? Any help will be appreciated. Also attached screenshot with job link in case somebody needed. screenshot here
I have just started on a project that involves building a web application replacement for an old Access application that was already backed by an SQL database.
The issue i have hit is that the Access application has a bunch of queries within it that use '*=' as condition operators (ie "where field1 *= 'Something'") which when i run the application cause it to crash.
I have tried to verify if the operator is valid or if the original developers have handed over an intentionally broken version of the application.
Can any one provide verification that '*=' (ie asterix equals) is or is not a valid operator in an Access query?
Don't worry; your original developers are not trying to pass you intentionally broken code. It's just that the code is very old.
*= (and its counterpart =*) were a non-standard SQL operator supported originally by Sybase SQL and inherited by Microsoft SQL Server in the mid-90's. *= meant LEFT JOIN (and its counterpart =* meant RIGHT JOIN)1
(Microsoft SQL Server was originally a repackaged edition of Sybase SQL, licensed from Sybase, adapted and recompiled to run on Microsoft's brand-new Windows NT Operating System. The partnership was eventually discontinued and Microsoft rewrote the code from scratch without Sybase's involvement, and that's the product we still have today)
The operator *= was a way to express LEFT JOIN operations, before there was such a thing as a LEFT JOIN operator:
SELECT *
FROM a, b
WHERE a.id *= b.id
Is the same as:
SELECT *
FROM a
LEFT JOIN b
ON a.id = b.id
These operators have been deprecated for more than a decade and are no longer supported at all, ever since SQL Server 2012. Using them in earlier versions of SQL Server is possible but requires the whole database to have a legacy-mode setting called compatibility_level to be set to 80 ("SQL Server 2000 mode").
Access has never supported these operators.2
You need to locate the code doing these outer joins and replace them with suitable LEFT JOIN (or RIGHT JOIN for =*) operations.
Finally, you should be aware that *= is not an exact mirror of LEFT JOIN. I don't remember all the details, but it goes something like this: If there are only two tables involved, or if there is a central table and all the LEFT JOINs go from the central table to immediate leaf tables, you can replace *= with LEFT JOIN in a straightforward fashion. However, if the outer joins cross more than two tables out, then *= behaves different than the naive replacement and you need to research it more carefully. I might be wrong about the details. Be careful!
1Compare this weird syntax for LEFT JOIN with this variant of an INNER JOIN, which is still perfectly acceptable today:
SELECT *
FROM a, b
WHERE a.id = b.id
Is exactly the same as:
SELECT *
FROM a
INNER JOIN b
ON a.id = b.id
2UPDATE: Upon re-reading your question I realize you were talking about pass-through queries executed by SQL Server. Then your choices depend on what version of SQL server you are using.
If you are able to run the application against SQL server 2008 R2 or earlier, you can temporarily switch compatibility_level to 80 to give you time to fix your queries.
More likely than not, you are having this problem precisely because you are trying to move the database to a version of SQL Server newer than 2008 R2, which doesn't support compatibility_level 80. When you loaded the database on a version of SQL Server newer than 2008 R2, the setting was automatically increased to the lowest value supported by your version of SQL Server (but higher than 80, which would no longer be supported). Then your only reasonable choice is to stay on SQL server 2008 R2 for now (and switch the database back to compatibility_level 80 if necessary) while you work on fixing the application queries.
I am using Crystal 2008
I am connecting to an excel sheet and SAP tables.
I would like to do a full outer join so that i can get all data from the SAP table and from the excel sheet.
Is there anyway of doing this?
Thanks
Rachael
Just to update everyone, The way I worked around this was to create two tables in SAGE.
One to take all the data from SAP, which I exported using Inaport.
The second table I created was for the excel sheet,
so I had to edit the data in the excel sheet so I could import it into SAGE CRM.
So a lot of messing around for a report
but at least now I can do my full outer join.
Hope that helps someone.
Rachael
Is there a default report in Sql Server that will output the permissions/securables history for given user or login? If not, does anyone know how to craft such a query? We had an incident recently where a user mysteriously lost insert permissions on a table, and we'd like to find out exactly what caused it.
The only way to figure this out is to read transaction log that stores details on each transaction. If your database was in full recovery mode then the info is somewhere in there.
Unfortunately you can’t do this using standard tools because MS doesn’t support this.
You can either get yourself a commercial log reader or try to hack this using undocumented commands like fn_dblog.
Check these out for more details
Read the log file (*.LDF) in sql server 2008
SQL Server Transaction Log Explorer/Analyzer
How to view transaction logs in sql server 2008
Here is a query for finding the permissions on a database. We have been using a variant of this query to copy permissions from one table to another table.
select *
FROM sys.database_permissions AS dp
INNER JOIN sys.objects AS o ON dp.major_id=o.object_id
INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id
INNER JOIN sys.database_principals AS dpr ON dp.grantee_principal_id=dpr.principal_id
I have the following code:
select order_number,received_date
from order_head
where order_head.order_number not in (select order_number from csa_log group by order_number)
and ordernature in ('02','03')
and received_date > '01.01.2010'
and buyer_code = 'GAP'
group by order_number,received_date
order by received_date desc
When run in crystal reports does not pull the same data as sql server express. It is pulling only one record as opposed to 7. Anybody have some insight? Thank you in advance. (I have a suspicion it has something to do with the nested statement).
Several possibilites come to mind.
First are you absolutely sure that Crystal Reports and the database you are querying are the same one. Amazing how often one is querying dev and another prod when you have these kinds of issues. Even if you don't believe this to be the case, check this anyway.
Permissions could be another reason for the discrepancy.
Finally confirm that the two queries are exactly the same. Use Profiler if possible to confirm this.
Usually I use SQL server profiler to check what SQL Statements Crystal is running behind the scenes. In your case is not possible because you are running SQL Server Express.
In Crystal you have the option of checking the actual SQL statement that Crystal is running by selecting "Database" and "Show SQL Statement" in the top menu.
Make sure that under Reports menu you are not putting any conditions in the Select Records.
Check that you are showing the fields in the detail and not in the header or footer. That is a common mistake.