exec sp_executesql nvarchar(max) truncating at 4000 characters
The Problem Sometimes you may need to write dynamic SQL. One example is writing query for running over linked server connections. You might write something like this Create Procedure prcTest @start...
View ArticleSQL Sever DB Mail Logs
If you use SQL Server Database mail sometimes you will have trouble and you want to see a log of all the emails that have been sent or failed to send. To do this there are some management views that...
View ArticleT-SQL Drop temp table if it exists
The Problem I often work in SQL Server with temp tables and they can be a pain when developing as you may have code like Create Table #tblTemp( Id int , Value nvarchar(32)) Insert Into #tblTemp select...
View ArticleSQL Server Script user with SID
The Problem When you move sql logins around servers the logins are created with an SID that uniquely identifies the login. Assume you setup two logins manually, one on your production server and one on...
View ArticleGrant Connect SQL Server – TSQL
The issue You are having connection problems to the database and all the permissions look correct but you cannot login. Fire up the SSMS and expand the Security tree at the individual database and you...
View Article