This site is a way for me to share photos and blog posts.

The blog will not be a diary, but instead a way of storing technical solutions and information.

As a professional computer programmer (and part time DBA/SysAdmin) it is a daily occurrence that I need to figure out technical solutions. And being human, I regularly forget what those solutions were.

So the blog is a way for me to quickly find the answer I've already worked out once, and hopefully other people on the web will discover them and find the information useful.

It will not be regularly updated!

Latest Blog...

TSQL Output Tables

Using output tables when inserting multiple rows

If you need to do processing on individual rows when inserting multiple rows into a database table I'd normally use a cursor to achieve what I want.

Instead you can use the OUTPUT instruction to place the details into a temporary table...

DECLARE @TEMP TABLE (NEWID INT, OUTID INT)
INSERT INTO DESTTABLE (VAL1, VAL2, OLDVALUE)
OUTPUT INSERTED.ID, INSERTED.OLDVALUE INTO @TEMP
SELECT VAL1, VAL2, ID
FROM SRCTABLE

This can also be used for UPDATE and DELETE but it's important to remember that on INSERT commands there must be a column for the old value to be inserted

Added 22/05/2026 11:51

Contact...

In the highly unlikely event you want to get in touch please email