I have a query with a "WHERE EXISTS()" clause.
When I execute it on SQL Developer it returns rows, but when I execute it in SQL Plus it doesn't.
Any one has a clue why this is happening?
Thanks in advance.
Regards,
Joao
If the query returns rows into one database session (say, created by SQL Developer) and doesn't return any rows in the other (say, created by SQL Plus) it means these sessions are different.
The difference may be:
database connected
connected user
current schema
NLS settings
FGAC policy
and so on...
As Juan mentioned, uncommitted data may affect this too.
If you look at some rows in SQL Developer, I'd say check if you can access these rows into SQL Plus (use something like select * from table where id = <id visible in SQL Developer>). If this returns some rows - see why it's filtered by your query in SQL Plus. If this doesn't return rows either see if you are connecting to a different data source or have no access to the data.
I would like to capture the truncate statements information along with the user/Login information for all database in my production server.
Example:
Use mydb
go
truncate table deleteme_table
I would like to capture the information into the table like the below
Table Operation Database Login Time
deleteme_table Truncate mydb sandeep.pulikonda 17-12-2014 17:50:00
If the above scenario is not possible please suggest possible ways to capture it
I am using SQL Server 2012 Standard version. So granular level audit are not supported for that version.
you can use the SQL Server Audit functionality and add an audit for those queries.
this article explains in detail how to obtain this.
Another good way of profiling your SQL Server is using SQL Profiler. Here is a SO question similar to yours and an answer describing how to use SQL Profiler to achieve the results.
SQL Server Profiler - How to filter trace to only display TSQL containing a DELETE statement?
Have a need to filter any and all SELECT statements against a particular table in a SQL Server 2008 database. Basically need to add an an additional condition (or create one) to all SELECTS.
So the server receives a request for SELECT * FROM PRODUCTS, we need to change this to
SELECT * FROM PRODUCTS WHERE Condition = 1
I'm open to just about any solution, anyone have any thoughts on how to achieve this?
Not our program, this would be a modification to an ERP package at the database level.
Embedded CLR is an available option, if it helps
How do you find the modification history for a certain table / row in SQL server 2000? Thanks.
you need to get a product that can read the transaction log like SQL Log Rescue or Apex SQL Log
i have a view that is using linked server to retrieve data from a remote server in SQL Server. On each time viewing the view, the results returned are vary. For example, 1st time execution may return 100 rows of records but on 2nd time of execution, rows returned are 120 rows. Any ideas what is the cause?
I have witnessed odd linked-server results that are a product of non-determinism written into the SQL itself, I.e. a TOP query written without an ORDER BY clause.
This problem, for example, where the chap had multiple non-unique foreign keys coming from a table source on the left hand side of a linked-server INNER JOIN, and wanted 10 rows from a remote sub-query to the right, where the end result was restricted to 10 rows itself, when it should have been greater than 10 rows.
Should definitely give your SQL a quick eye for such curiosities.
The data on the linked server changed between executions?
Is your SQL Server fully patched? SQL Server 2008 and 2005 both have bug fixes out related to incorrect query results from linked servers.
Here is one example:
969997 FIX: You receive an incorrect result when you query data from a linked server that is created by using an index OLE DB provider in SQL Server 2005 or in SQL Server 2008
Is the linked server also a SQL Server? If not, perhaps a buggy driver? I've seen odd results, for example, due to an old Informix ODBC driver. Are you able to run something akin to SQL Profiler on the linked server to see what command it's receiving?
I'm not sure what the answer is, but (assuming that your counts of 100 and 120 are accurate) can you not capture the data from the two runs and compare it? That might give you some clues as to what's going on. For example, is it completely different datat, or is it duplicate rows (in the 120 row batch).