Creating table variable in SQL server 2008 R2

@tableName Table variables are alive for duration of the script running only i.e. they are only session level objects. To test this, open two query editor windows under sql server management studio, and create table variables with same name but different structures. You will get an idea. The @tableName object is thus temporary and used … Read more

SQL Server Profiler: Templates not showing / missing

I have managed to resolve the issue, I solved it by following this link’s suggestion: http://www.mattbutton.com/2011/06/01/sql-profiler-templates-missing/ The following comes from the link: If you are connecting to a SQL server with the SQL profiler and none of your templates are showing up, compare the versions of the SQL profiler you are running and the version … Read more

How to delete from source using MERGE command in SQL Server 2008?

You can use the output clause to capture the modified/inserted rows to a table variable and use that with a delete statement after the merge. DECLARE @T TABLE(EmployeeID INT); MERGE Target1 AS T USING Source1 AS S ON (T.EmployeeID = S.EmployeeID) WHEN NOT MATCHED BY TARGET AND S.EmployeeName LIKE ‘S%’ THEN INSERT(EmployeeID, EmployeeName) VALUES(S.EmployeeID, S.EmployeeName) … Read more

Syntax error near ‘of’ in the full-text search condition ‘control of’

Enclose the keywords in double quotes if you want to search exactly for control of SET @Keywords=””control of”” If you want to search for control and of, use the following: SET @Keywords=”control AND of” But server may consider of as a garbage or stop word, so in this case use the following: SET @Keywords=”control AND … Read more

SQL Server 2008 replication failing with: process could not execute ‘sp_replcmds’

When I had this problem, my database didn’t have an owner set properly. I had restored a database from another windows domain, right clicked the database -> properties and verified in the “general” tab that the owner was set correctly. However, in the “files” tab, owner was not set at all. As soon as I … Read more

tech