Tag Archives: T-sql

Script to check Job history of a particular job.

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

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

System.Data.SqlClient.SqlException: The RPC security information for the Publisher is missing or invalid. Use sp_link_publication to specify it. Updateable Subscriptions: Rolling back transaction

System.Data.SqlClient.SqlException: The RPC security information for the Publisher is missing or invalid. Use sp_link_publication to specify it. Updateable Subscriptions: Rolling back transaction Resolution:- Add a link to the publisher server on the subscriber database for the updatable subscription (transactional replication). … Continue reading

Posted in Replication, SQL Server, Troubleshooting | Tagged , , , | Leave a comment

How to run multiple SQL scripts

Scenario 1:- Create a .bat file with the below code and store the .bat file in the folder containing all the .sql scripts. setlocal SET SQLCMD=sqlcmd -S<servername\instancename> -d<database name> -E for %%d in (*.sql) do %SQLCMD% -i%%d endlocal Double click … Continue reading

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

Execute SQL script from command prompt

We are often required to run certain scripts or deploy scripts to sql server using command prompt; here how we can do it seemlessly. Open command prompt and type in the below sqlcmd mentioning the relevant servername /database name and … Continue reading

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

SQL Script to add and Remove Database role members

/*========================================================== Author: Suleman Mohammed Description: Scripts out statements to add & drop Database role members for each of the Database roles, ordered by Database role name and Member name ===========================================================*/ SELECT [Database Role] = r.name , [Member] = m.name , … Continue reading

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

SQL Script to add and Remove SQL server role members

/*========================================================= Author: Suleman Mohammed Description: Scripts out statements to add & drop SQL server role members for each of the SQL server roles, ordered by Server role name and Member name ==========================================================*/ SELECT [Server Role] = r.name ,[Member] = m.name … Continue reading

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