Category: SQL Server

Truncating A Replicated Table 1

Truncating A Replicated Table

On a recent project that I was working on we came across an issue where we needed to replicate several databases on a new server.  Much of the ETL had places where tables were truncated and reloaded.  Normally this is...

CREATE SCHEMA Syntax Error 0

CREATE SCHEMA Syntax Error

Recently while creating a script to migrate the new holding tables over to the stage and production machines I ran into a little issue.  The holding table we are using in this case houses several different sets of data for...

Comma Delimited List with COALESCE 0

Comma Delimited List with COALESCE

There may be a day when you need to create your own comma delimited list from data contained in a SQL table.  Sure you could build a cursor and go through each row adding a comma after each record.  The...

7

Server ‘SERVERNAME’ is not configured for RPC

I recently was doing some development on my local machine and needed to pull data from a linked server.  I set up the linked server and everything was working great.  Executing queries to pull the data to my machine was...

Removing The Date From The End of a String 0

Removing The Date From The End of a String

Occasionally there may be the need to remove the date from the end of a string.   This can be accomplished by using PATINDEX along with SUBSTRING.  We will use PATINDEX to find where the date begins and then SUBSTRING to remove the...

0

Joining Tables That Contain NULL Values

As you can see we have two tables, with the same values. Joining on these tables is no problem at all.  Simple, right?  Well, take a look at what happens when we try to join on the column containing the NULL values....

Calculate the Date of Previous Sunday 1

Calculate the Date of Previous Sunday

There are a number of ways that you can calculate dates using T-SQL.  A common practice is to find the first day of the week which can be accomplished easily by using the following function. SELECT DATEADD(wk, DATEDIFF(wk,0,GETDATE()), 0) However,...

0

Use SQL from the Command Line

More often than not an execute SQL task in SSIS will do the trick.  If not, then the data flow will accomplish whatever objective is set out.  Occasionally those can become cumbersome in a package to accomplish something simple.  In...

18

SQL Maintenance Plan Doesn't Delete Backups

I recently created a maintenance plan for our server to backup all the databases on a daily basis.  In the cleanup step I set it to delete backups older than 7 day.  I let the plan run for a week...

SQL UPDATE Using a Join 0

SQL UPDATE Using a Join

You may need to do an update on joined tables to get a more conditional update.  For instance, I have a Student table as well as an AcademicStatus table.  The Student table contains all the students (profound, I know) and...