Can varbinary data type be compressed?

Data compression is one of the useful tools of sql server. But not all data types can be really compressed. What about varbinary data type?

Database principal permissions script


With the GUI of SSMS is it not easy to grasp all permission and role membership of a database principal. With the code following, you can get all object level and schema level permissions and role membership. If the principal is member of a role, the role membership is extracted until the end.

Create Index Rebuild Script With DMV


Creating an operation script via T-SQL is a common way. With T-SQL code following, you can create index rebuild script for all indexes which is fragmented more then 20 % .

Key Points Of Logon Trigger

SQL Server has a useful utility which is logon trigger. But if you don't be careful enough it can be very dangerous, even SQL Server instance may be out of service.

Last Execution Time Of A Stored Procedure

Sometime it is a critical question that when a stored procedure is run. Because if you want to drop a stored procedure which is not used any more, you must be sure that it is not used.

Shrink Database Files By Small Amount

It is not recommended to shrink database files. But sometimes it becomes necessary to shrink a database file. Because it is not needed that much free space any more.

Stop processing a batch which is separated with 'GO'


If you have batch scripts which is separated with 'GO' statement, it is not easy to stop processing the rest of the script in case of an error.

Randomize Selection Order

Sometimes it is a need to select random rows from a table or view. You can use NEWID() function to order rows randomly. Here is the code.

Generate Database Script Permissions


Some times DBAs get tired of slavery work. One of them is generating database script with management studio.

Can not rebuild online, then reorganize it.

If an index cannot be rebuilt online you can reorganize it.

Clustered index keys must not be used as include column

Mostly of tables have a clustered index. In addition, non-clustered indexes also created in need. To improve index performance, some columns may be included to non-clustered index.

How to decide clusted index key set


Generally speaking it is said that every table must have a clustered index. But selecting index key set for clustered index is not easy.

Compress Archive Databases, Gain Disk Space And Improve Performance


Database Compression is one of the useful functionalities that is became available with SQL Server 2008. By compressing tables and indexes of archive database, you can gain 6-8 time disk space and reduce I/O workload.

Opendatasource And 'NT AUTHORITY\ANONYMOUS LOGON' Error


When you use opendatasource to query something, you may get the error "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'." 

Change object schema

Sometimes it is needed to change schema of object. Because objects are created under wrong schema.
Unfortunately it is not possible to change schema using Management Studio.

Database compatibility level check with Policy Based Management

Sometime database compatibility level is lower than server level. Normally database compatibility level must be up to date. If you have lots of SQL Servers, to check all databases manually is not  the optimum way.

Policy Based Management And Filtering


With policy based management, it is possible to define policies and evaluate the policies against lots of instances and againsts lots of objects. While evaluating policies, to exclude the object and the servers which are out of scope will optimize the management.