473,569 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script for Transfering Database Diagram

I've been trying to get the scripts posted earlier to the group by
Clay Beatty to work properly. Using the three components he posted, I
have managed to get a new SP generated. However, when I paste this
scrip into a new copy of the original database (different name, same
structure as a test), I get an Invalid Object Name for the temp table
#PersistedVaria bles.

Has anyone run into something like this before? Or used the scripts I
mentioned successfully? Help would be appreciated. The resulting
section of code causing the error is posted below. This is running on
SQL-Server 2000.

Tim Pascoe

CREATE PROCEDURE [dbo].[Create Diagrams] AS

------------------------------------------------------------------------
-- Database Diagram Reconstruction Script
------------------------------------------------------------------------
-- Created on: 2004-07-19 11:54:43.327
-- From Database: CABIN
-- By User: dbo
--
-- This SQL Script was designed to reconstruct a set ofdatabase
-- diagrams, by repopulating the system table dtproperties, inthe
-- current database, with values which existed at the timethis
-- script was created. Typically, this script would be createdto
-- backup a set of database diagrams, or to package up thosediagrams
-- for deployment to another database.
--
-- Minimally, all that needs to be done to recreate the target
-- diagrams is to run this script. There are several options,
-- however, which may be modified, to customize the diagrams tobe
-- produced. Changing these options is as simple as modifyingthe
-- initial values for a set of variables, which are definedimmediat ely
-- following these comments. They are:
--
-- Variable Name Description
-- -------------------------------------------------------------------
-- @TargetDatabase This varchar variable will establishthe
-- target database, within which thediagrams
-- will be reconstructed. This variableis
-- initially set to database name fromwhich
the
-- script was built, but it may bemodified as
-- required. A valid database namemust be
-- specified.
--
-- @DropExistingDi agrams This bit variable is initially setset to a
-- value of zero (0), which indicatesthat any
-- existing diagrams in the target
-- to be preserved. By setting thisvalue to
-- one (1), any existing diagrams inthe target
-- database will be dropped prior to
-- reconstruction. Zero and One are theonly
-- valid values for the variable.
--
-- @DiagramSuffix This varchar variable will be usedto append
-- to the original diagram names, asthey
-- existed at the time they werescripted. This
-- variable is initially set to take onthe
-- value of the current date/time,although it
-- may be modified as required. Anempty
string
-- value would effectively turn off thediagram
-- suffix option.
--
------------------------------------------------------------------------

SET NOCOUNT ON

-- User Settable Options
------------------------
Declare @TargetDatabase varchar (128)
Declare @DropExistingDi agrams bit
Declare @DiagramSuffix varchar (50)

-- Initialize User Settable Options
-----------------------------------
SET @TargetDatabase = 'CABIN2'
SET @DropExistingDi agrams = 0
SET @DiagramSuffix = ' ' + Convert(varchar (23), GetDate(),121)
-------------------------------------------------------------------------
-- END OF USER MODIFIABLE SECTION - MAKE NO CHANGES TO THELOGIC BELOW
--
-------------------------------------------------------------------------
-- Setting Target database and clearing dtproperties, ifindicated
------------------------------------------------------------------
Exec('USE ' + @TargetDatabase )
IF (@DropExistingD iagrams = 1)
TRUNCATE TABLE dtproperties
-- Creating Temp Table to persist specific variables
-- between Transact SQL batches (between GO statements)
-------------------------------------------------------
IF EXISTS(SELECT 1
FROM tempdb..sysobje cts
WHERE name like '%#PersistedVar iables%'
AND xtype = 'U')
DROP TABLE #PersistedVaria bles
CREATE TABLE #PersistedVaria bles (VariableName varchar (50)NOT NULL,
VariableValue varchar (50)NOT NULL)
ON [PRIMARY]
ALTER TABLE #PersistedVaria bles ADD CONSTRAINT
PK_PersistedVar iables PRIMARY KEY CLUSTERED
(VariableName) ON [PRIMARY]
-- Persist @DiagramSuffix
-------------------------
INSERT INTO #PersistedVaria bles VALUES ('DiagramSuffix ',
@DiagramSuffix)
GO
-- Insert a new dtproperties row
--------------------------------
INSERT INTO dtproperties (objectid,
property,
value,
uvalue,
lvalue,
version)
VALUES (0,
'DtgSchemaOBJEC T',
null,
null,
null,
0)
DELETE #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
INSERT INTO #PersistedVaria bles VALUES ('NextObjectid' ,
Convert(varchar (15),
@@IDENTITY))
Declare @NextObjectid int
SELECT @NextObjectid = Convert(int, VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
UPDATE dtproperties
SET Objectid = @NextObjectid
WHERE id = @NextObjectid
GO

-- Insert a new dtproperties row
--------------------------------
Declare @NextObjectid int
SELECT @NextObjectid = Convert(int, VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
INSERT INTO dtproperties (objectid,
property,
value,
uvalue,
lvalue,
version)
VALUES (@NextObjectid,
'DtgSchemaGUID' ,
'{EA3E6268-D998-11CE-9454-00AA00A3F36E}',
'{EA3E6268-D998-11CE-9454-00AA00A3F36E}',
null,
0)
GO

-- Insert a new dtproperties row
--------------------------------
Declare @DiagramSuffix varchar (50)
SELECT @DiagramSuffix = Convert(varchar (50), VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'DiagramSuffix'
Declare @NextObjectid int
SELECT @NextObjectid = Convert(int, VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
INSERT INTO dtproperties (objectid,
property,
value,
uvalue,
lvalue,
version)
VALUES (@NextObjectid,
'DtgSchemaNAME' ,
'CABIN Detail' + @DiagramSuffix,
'CABIN Detail'+ @DiagramSuffix,
null,
1)
GO

-- Insert a new dtproperties row
--------------------------------
Declare @NextObjectid int
SELECT @NextObjectid = Convert(int, VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
INSERT INTO dtproperties (objectid,
property,
value,
uvalue,
lvalue,
version)
VALUES (@NextObjectid,
'DtgDSRefBYTES' ,
'2502',
'2502',
null,
12)
GO

-- Insert a new dtproperties row
--------------------------------
Declare @NextObjectid int
SELECT @NextObjectid = Convert(int, VariableValue)
FROM #PersistedVaria bles
WHERE VariableName = 'NextObjectid'
INSERT INTO dtproperties (objectid,
property,
value,
uvalue,
lvalue,
version)
VALUES (@NextObjectid,
'DtgDSRefDATA',
null,
null,
cast('0' as varbinary(10)),
12)
GO
---SNIP----
Jul 20 '05 #1
1 3542

"Tim Pascoe" <ti********@cci w.ca> wrote in message
news:19******** *************** ***@posting.goo gle.com...
I've been trying to get the scripts posted earlier to the group by
Clay Beatty to work properly. Using the three components he posted, I
have managed to get a new SP generated. However, when I paste this
scrip into a new copy of the original database (different name, same
structure as a test), I get an Invalid Object Name for the temp table
#PersistedVaria bles.

Has anyone run into something like this before? Or used the scripts I
mentioned successfully? Help would be appreciated. The resulting
section of code causing the error is posted below. This is running on
SQL-Server 2000.

Tim Pascoe


<snip>

I'm not familiar with this code, but it appears to start out as a procedure,
and then turns into a series of TSQL batches. When the first GO command is
reached, this executes the CREATE PROCEDURE statement with the code up to
that point as the procedure text. Subsequent sections between GO commands
are executed as independent batches, however since the #PersistedVaria bles
table is created in the procedure, not in a batch, it doesn't exist when the
batches try to find it.

I can't really say more than that, as I don't know how this procedure is
intended to be used - you may want to review the original posting again. By
the way, a procedure name with a space in it is probably a bad idea, as many
tools (and many human beings) don't always handle that very well.

Simon
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1606
by: Ian | last post by:
Hi there, Maybe this is a strange quesiton but maybe someone can advise. I have created a database and it is getting larger and larger, I wonder if there any tools when you can actually document the database i.e. create database maps and see all the joins and what field has what type, and what comments assigned. Basically so later if I...
6
34043
by: Clay Beatty | last post by:
When you create database diagrams in Enterprise Manager, the details for constructing those diagrams is saved into the dtproperties table. This table includes an image field which contains most of the relevant infomation, in a binary format. SQL Enterprise manager offers no way to script out those diagrams, so I have created two Transact...
7
7593
by: Dr. Know | last post by:
I am working on an ASP page that writes to several databases, ranging from MDBs to x-base. One of the tasks involves using an existing highest value from the DB and incrementing it before inserting a new record. I am using Application.Lock and .Unlock together with an application variable to negotiate access to the DB routine to one...
3
1979
by: Nolan Madson | last post by:
Can someone point me to a definition of a "database map"? My understanding is that it is a higher level diagram showing the relationship of business subject areas to tables in a database. However, in some of the threads here people appear to use "database map" and "data model" interchangeably. TIA Nolan Madson
8
1723
by: Steve Jorgensen | last post by:
Recently, I've been working on an Access application that is supposed to be the prototype for a larger system that will be developed by a team using Oracle tools, etc. As such, everything I do must not only work, but it must be easy to understand and duplicate. Now, obviously one of the goals should be to avoid anything too "clever", but I...
9
1355
by: Wayne Wengert | last post by:
I am attempting to incorporate some techniques I found in an MSDN article into one of my aspx pages. It basically adds a new class that Inherits from the System.Web.UI.Page and includes some new subs and function (some are shown below). I have a page based on that new class and in my code where a user clicks on a Save button (saves data to my...
2
51972
by: sangu_rao | last post by:
Hi, I have to prepare an ER diagram for the objects in my SQL Server database. I have used the option "DIAGRAMS" in EnterPrise Manager of SQL Server 2000. It is creating the diagram for the selected tables (but the diagram contains only the table which i have selected. It is not displaying its depended tables). But i am not able to export it...
10
2052
by: Paul H | last post by:
I am trying to get the spec for a database. The trouble is the client frequently blurts out industry jargon, speaks insanely quickly and is easily sidetracked. They are currently using around 30 different spreadsheets and they want me to refine those spreadsheets in to an Access DB. The current system is a complete mess. My gut feeling is...
0
2125
by: viepia | last post by:
Hi, My project writes records to a new SQL Server 2005 database with currently 18 tables. When I change the Database Diagram for my database I save the copy the list of changed tables to a notepad text file; then one at a time I delete the changed tables from my DBML Diagram and drag a replacement from the Server Explorer Table list....
0
7695
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.