Category Archives: T-SQL Scripts

Add a table to an Existing Transactional Replication using T-SQL and Generate Snapshot using T-SQL

Replace the PublishedDB with your published database and TableName with the table name you want to replicate The next step is to start the snapshot agent to pick up the new tables added to replication and replicate across to Subscriber … Continue reading

Posted in Replication, SQL Server, T-SQL Scripts, Transactional Replication, Tricks | Leave a comment

Script to check Job history of a particular job.

Posted in SQL Server, T-SQL Scripts | Tagged , | Leave a comment

Script to get All database file sizes, used and unused space

Posted in SQL Server, T-SQL Scripts | Tagged , , , | Leave a comment

Merge Statement for a SQL Server 2000 compatible Database

I have recently been asked if we can write a Merge T-sql to handle inserts and updates in the same statement for a Database on SQL Server 2008 at SQL 2000 compatibility level. The answer is YES and NO; I … Continue reading

Posted in SQL Server, T-SQL Scripts | Tagged , , , , , , | 3 Comments

Database Migration Automated

Its been a while since I posted anything here… Phew… Finishing a very tight deadline and critical Database Migration Project today. I have done myself some justification by automating the Database Migration work, that would otherwise require me to perform … Continue reading

Posted in .bat scripts, LogShipping, Replication, RoboCopy, Setup, SQL Server, SSIS, T-SQL Scripts, Transactional Replication, upgrade | Tagged , , , | Leave a comment

SQL Server Health Checks

I have been working on automating SQL Server Health checks for a while now and use this post to share my work with the community. You will find me constantly updating this post and adding more checks and Content/Scripts . … Continue reading

Posted in SQL Server, SQL Server Health Checks, T-SQL Scripts, Uncategorized | Tagged , , | Leave a comment

Split a string using a table Variable

Was just playing around with Table variables and thought of a practical problem lot of people approached to me with. Thought its worth documenting on how I do it so somebody can reuse the trick. Given a set of names … Continue reading

Posted in SQL Server, T-SQL Scripts, Tricks | Tagged , , | 1 Comment

Script to find when a table was last modified

I have had a question from one of my collegues, how to find when was a table last modified. Here is what I suggest to use to find when was tables schema changed and when was the last user update/delete … Continue reading

Posted in SQL Server, T-SQL Scripts, Tricks | Tagged , | Leave a comment

SQL Server configurations List

Was just checking sql server configuration of my sql installation via t-sql and found a way of listing which sql server configurations can be changed dynamically. Here is the list of SQL Server configurations with their descriptions, that can be … Continue reading

Posted in SQL Server, T-SQL Scripts, Tricks | Tagged | Leave a comment

Read SQL Server error Log and SQL agent log

Often DBA’s need to quickly look at sql server error log and agent logs to find something speicific, and it takes awful lot of time to go through a huge error log file; and you want to get the information … Continue reading

Posted in SQL Server, sql server error log, T-SQL Scripts, Tricks | Tagged , , , | Leave a comment