Monday, August 26, 2013
SET XACT_ABORT Option and Transaction Behavior
I initially tried the below query to test the above mentioned situation. Note that I did not change the default setting of XACT_ABORT option. The default is set to OFF.
Tuesday, June 25, 2013
“Table Alias”, How it behaves?
One of my colleagues asked me a question about a simple T-SQL query which uses table alias. See the below T-SQL code;
USE AdventureWorks2012
GO
SELECT E.loginID,HumanResources.Employee.JobTitle FROM HumanResources.Employee E
The above query used a table alias “E” and in SELECT list one column refers with table alias while the other column referring full table name. Seems like technically correct query. However the query returned the following error.
Msg 4104, Level 16, State 1, Line 2
The multi-part identifier "HumanResources.Employee.JobTitle" could not be bound.
As per the error message, use of table name, “HumanResources.Employee” to refer JobTitle column is incorrect. When you remove HumanResources.Employee in the SELECT list then the query works fine.
The theory behind this is when you have a table alias, it logical rename the table to table alias. So if you want to refer the table in the query, it needs to use table alias instead of the actual table name.
Relational algebra explains this more clearly.
The relevant operator for table alias in relational algebra (RA) is RENAME. As SQL derived from RA it is always better to learn RA before learning SQL.
Saturday, May 11, 2013
How to get database sizes
There are several ways to get database sizes in a server. Following three system tables has the information to get database sizes.
sys.sysfiles
sys.database_files
sys.dm_db_file_space_usage
You also can use following system stored procedure.
exec sp_spaceused
However the easiest way is to use SP_HELPDB system stored procedure. Below script used that SP to get the database sizes in a server.
create table #spdbdesc
(
dbname sysname,
dbsize nvarchar(13) null,
owner sysname null,
dbid smallint primary key,
created nvarchar(11),
dbdesc nvarchar(600) null,
cmptlevel tinyint
)
INSERT INTO #spdbdesc
exec SP_HELPDB
SELECT *
FROM #spdbdesc
Monday, December 31, 2012
In-Memory OLTP technology to SQL Server
High transaction throughput is vital in today’s applications. No matter the database product delivered with rich set of features if it unable to handle the high transaction throughput. It seems that MS SQL Server product team has seriously considered this and they have developed in-memory technology to achieve the goal and it will be released with the next major version of SQL Server. The code name of the project is “Hekaton”. Below are some links I found about “Hekaton” and thought of sharing.
How Fast is Project Codenamed “Hekaton” – It’s ‘Wicked Fast’!
SQL Server In-Memory OLTP technology Project “Hekaton” Riles Oracle VP
Friday, November 30, 2012
MongoDB to the Windows Azure cloud
In my previous post, it is mentioned the need of NoSQL product from Microsoft. I did some Googling and found several interesting posts where Microsoft and 10gen (one of the famous document oriented database vendors who invented MongoDB) has come to a collaboration to bring MongoDB to the Windows Azure cloud. Below are the links found related to Microsoft and MongoDB.
Sunday, November 25, 2012
Future versions of SQL Server?
It is publicly known fact that RDBMSs have well known limitations when it comes to unstructured data management. This is the reason to emerged new database technologies like NoSQL. It is true that NoSQL is not a replacement for RDBMS. However the time has come to include NoSQL features into RDBMS products (then it can’t be called it as RDBMS) or introduce brand new NoSQL product from RDBMS vendors. We need to wait and see how Microsoft react to these new technology trends and how SQL Server change accordingly. Oracle has already announced their NoSQL version called Oracle NoSQL Database. Will Microsoft come up with new NoSQL product?
Thursday, November 1, 2012
Know about your SQL Server memory
SQL Server 2012 Memory Manager KB articles
Pushing the Limits of Windows: Virtual Memory
Pushing the Limits of Windows: Physical Memory
How to interpret Disk Latency
I was analyzing IO stats in one of our SQL Servers and noticed that IO latency (Read / Write) are very high. As a rule of thumb, we know tha...
-
This can happen due to many factors like lack of indexes, out of dates statistics, if it returns a large number of records, etc. I observed...
-
There are several ways to get database sizes in a server. Following three system tables has the information to get database sizes. sys . sy...
-
This post is for SQL Server Database Administrators who have find difficulty in some situations when identifying slow running queries. The D...