﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Rich Yarger  / Update 2 databases with 1 script / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 08:55:42 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Update 2 databases with 1 script</title><link>http://www.sqlservercentral.com/Forums/Topic1077342-2916-1.aspx</link><description>My apologies on the way this got published and formatted.  I was trying to get some additional DDL put into the publication, and for some reason I thought that this "SQL Scripts Manager" was the way to do this (from other scripts that I have seen published out here in the past).Here are the 2 tables and the 1 DML trigger needed in addition to the script.  Please again - feel free to modify as you need, and definitely improve as you wish!VERSION Table[code="sql"]/****** Object:  Table [dbo].[VERSION]  Script Date: 03/03/2011 12:12:12 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[VERSION](	[TheKey] [nvarchar](20) NOT NULL,	[TheValue] [nvarchar](10) NOT NULL,	[TheTextValue] [nvarchar](10) NOT NULL, CONSTRAINT [PK_TheKey] PRIMARY KEY CLUSTERED (	[TheKey] ASC,	[TheValue] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY]GO[/code]VERSION_HISTORY Table[code="sql"]/****** Object:  Table [dbo].[VERSION_HISTORY]  Script Date: 03/02/2011 12:12:12 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOSET ANSI_PADDING ONGOCREATE TABLE [dbo].[VERSION_HISTORY](	[ID] [int] IDENTITY(1,1) NOT NULL,	[TheKey] [nvarchar](20) NOT NULL,	[LastUpdate] [datetime] NOT NULL CONSTRAINT [DF_VERSION_HISTORY_LastUpdate]  DEFAULT (getdate()),	[TheValue] [nvarchar](10) NOT NULL,	[TheTextValue] [nvarchar](10) NOT NULL, CONSTRAINT [PK_ID4] PRIMARY KEY CLUSTERED (	[ID] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY]GO[/code]VH-INSERT Trigger[code="sql"]--Creates a Trigger for the VERSION table so that upon an update, the VERSION_HISTORY table receives the info.IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[Trg_VH-INSERT]'))DROP TRIGGER [dbo].[Trg_VH-INSERT]SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO--Create TriggerCREATE TRIGGER [dbo].[Trg_VH-INSERT]ON [dbo].[VERSION]AFTER UPDATEASBEGIN--Creates new VERSION_HISTORY table record when an UPDATE takes place on the VERSION table. ~RWY 2/23/2011	INSERT INTO dbo.VERSION_HISTORY ([TheKey],[TheValue],[TheTextValue])        SELECT TheKey, TheValue, TheTextValue        FROM inserted        WHERE TheTextValue IS NOT NULLENDGO[/code]</description><pubDate>Sun, 13 Mar 2011 12:19:49 GMT</pubDate><dc:creator>SQL_ME_RICH</dc:creator></item><item><title>Update 2 databases with 1 script</title><link>http://www.sqlservercentral.com/Forums/Topic1077342-2916-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/scripts/DDL/72638/"&gt;Update 2 databases with 1 script&lt;/A&gt;[/B]</description><pubDate>Sat, 12 Mar 2011 11:32:35 GMT</pubDate><dc:creator>SQL_ME_RICH</dc:creator></item></channel></rss>