Simplest Merge example

Here’s the simplest example of a working Merge statement I could make. Its great to build-on to test the formatting of ‘real’ merges.

drop table d, s
	
-- destination table containing old data
	create table d (id int, fruit varchar(50), tasty int)
	insert into d values (1,'apple', 5), (2,'orange', 5)
	select * from d

-- source table containing unchanged, updated, and new data
	create table s (id int, fruit varchar(50), tasty int)
	insert into s values (1, 'apple', 5), (2,'orange', 0), (3,'banana', 9) 
	select * from s

--merge statement
	merge d target
	using s source
	on target.id = source.id

	when matched then 
	update set tasty = source.tasty

	when not matched then 
	insert values (id, fruit, tasty);

-- show new destination table
	select * from d

To remove an item from the ‘Recent Projects’ list on the Start-Page of SQL 2008r2 BIDS

– Hover over the ‘Recent Project’ you want to remove.
– Note the path shown at the bottom-left of the screen.
– Go to that path and delete the dtproj or sln file noted previously.
– Left-click the item in BIDS ‘Recent Projects’ and click YES to the message ‘Remove this item blah blah blah …’.

A severe error occurred on the current command. The results, if any, should be discarded.

This worrying error was fixed by naming columns selected from a linked server EG:-

select * from openquery([someserver\someinstance],
'select * from [databasename].[schema].[tablename]')

Msg 0, Level 11, State 0, Line 4
A severe error occurred on the current command. The results, if any, should be discarded.

select * from openquery([someserver\someinstance],
'select [LifeID] from [databasename].[schema].[tablename]')

(111878 row(s) affected)

SSIS Error -1071607685

We had this error number written multiple times into an SSIS errors table. It seems to be one of those Microsoft generic codes.

In this instance it indicated that we were using ‘fast load’ to write to a table, and one (or more) of the rows was failing.

To find the erroneous row(s), and get specific error(s), we changed to ‘normal’ load (called “Table or View”), which is fully-logged.