Monthly Archives: October 2010

@@TRANCOUNT

@@TRANCOUNT is a global system variable that count transaction’s command. Per a BEGIN TRAN or COMMIT|ROLLBACK TRAN it counts once. note! If we COMMIT a transaction it counts back to zero. If it’s not zero means that a transaction block is uncompleted.

| Leave a comment

SCHEMABINDING

SCHEMABINDING is a property that very useful for safety in views. If anyone wanna to change the table column that our view use it, “SCHEMABINDING” do not allow that chang. In some cases such as “Indexed views”, using “SCHEMABINDING” in view creation script is … Continue reading

Posted in Joy of T-SQL | Leave a comment

Remove duplicate records in two or more columns

If we wanna have a primary key or unique index on two or more columns, using CTE and DERIVED TABLE with ROW_NUMBER is very useful to remove dup records. In fact that’s CTE usage is because we cannot use RANKING FUNCTIONS in … Continue reading

Posted in Joy of T-SQL | Leave a comment

Remove duplicate records in a column

I published  some posts about dup records. But this is a beautiful logical query. Notice that it’s not optimized query.

Posted in Joy of T-SQL, T-SQL Tips & Tricks | Leave a comment

SELECT INTO

We use SELECT INTO instead of create a new table and insert data into it.If we just wanna to create a copy of a table just like bellow query use where clause with false statement.It creates but not populated.

Posted in Joy of T-SQL | Leave a comment

disable windows authentication in sql server

To disable windows authentication in sql server:

Posted in Database Administration, Joy of T-SQL, T-SQL Tips & Tricks | Leave a comment

SET QUOTED_IDENTIFIER ON

Sometimes we can’t use single quote. For example we want to update a column and our data contain single quote.In such cases we can use double quote instead of single quote if we SET QUOTED_IDENTIFIER ON.Below first query fails.

Posted in Joy of T-SQL, T-SQL Tips & Tricks | Leave a comment

CHECKDB

According to MOB, DBCC CHECKDB Checks the allocation, structural, and logical integrity of all the objects in the specified database.

Posted in Database Administration, SQL General Information, T-SQL Tips & Tricks | Leave a comment

ANSI_NULLS

NULL comparison conditions are different from others. Because NULL means UNKNOWN, there are three conditions when using NULL: TRUE FALSE UNKNOWN This is because a value that is unknown cannot be compared logically against any other value. T-SQL supports an extension … Continue reading

Posted in Joy of T-SQL, T-SQL Tips & Tricks | Leave a comment

Beginning SQL Server 2005 for Developers From Novice to Professional

because now I’m behind isa server I cannot upload this book photo. But later I upload its photo. And this is photo: Again a very good book from Apress. Robin Dewson in this book introduce sql server in details. He … Continue reading

Posted in SQL General Information | Leave a comment