I am working on a project where I need to be able to quickly tell if changes in data contained in a row have occurred. After playing around with HASHBYTES unsatisfactorily, I did some searches and came across this post: http://sqlserverplanet.com/data-warehouse/detecting-row-level-changes
This appears to be a decent method of discovering changes without the overhead of doing a full byte by byte compare.
Showing posts with label TSQL. Show all posts
Showing posts with label TSQL. Show all posts
20140825
20140123
List Tables from ODBC
I was wanting to see the available catalogs on a linked server, but the catalogs branch was empty, so I thought I would try finding a query that would show them.
I'd done this before with TSQL on SQL Server:
SELECT * FROM sys.objects
or
SELECT * FROM sysobjects
But I had never done it for an ODBC linked server (this one happens to be Oracle)
After some conversations and searching I came up with this:
SELECT * FROM USER_TAB_PRIVS;
and for permissions:
SELECT * FROM USER_ROLE_PRIVS;
If you are also using a Linked Server you will need to use the OPENQUERY function
SELECT * FROM OPENQUERY([Linked Server Name], 'SELECT * FROM USER_TAB_PRIVS;')
You may even need to build the text and run it using sp_executesql:
DECLARE @Query nvarchar(max) = 'SELECT * FROM OPENQUERY([Linked Server Name], ''SELECT * FROM USER_TAB_PRIVS;'')'
PRINT @Query
exec sp_executesql @Query;
I'd done this before with TSQL on SQL Server:
SELECT * FROM sys.objects
or
SELECT * FROM sysobjects
But I had never done it for an ODBC linked server (this one happens to be Oracle)
After some conversations and searching I came up with this:
SELECT * FROM USER_TAB_PRIVS;
and for permissions:
SELECT * FROM USER_ROLE_PRIVS;
If you are also using a Linked Server you will need to use the OPENQUERY function
SELECT * FROM OPENQUERY([Linked Server Name], 'SELECT * FROM USER_TAB_PRIVS;')
You may even need to build the text and run it using sp_executesql:
DECLARE @Query nvarchar(max) = 'SELECT * FROM OPENQUERY([Linked Server Name], ''SELECT * FROM USER_TAB_PRIVS;'')'
PRINT @Query
exec sp_executesql @Query;
Labels:
Linked Server,
list tables,
ODBC,
Oracle,
sp_executesql,
SQL Server,
tables,
TSQL
20140122
TSQL Temp Tables # vs ##
Using the # prefix for a temporary table creates that table in the tempdb. The ## prefix does the same, but makes it global, so you can access it from other procedures.
Both will persist and need to be dropped to free up memory and disk space.
More here.
Both will persist and need to be dropped to free up memory and disk space.
More here.
Subscribe to:
Posts (Atom)