473,701 Members | 2,398 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 3551

"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
1616
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 decide to go to it, I can check a kind of database
6
34162
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 SQL components, one User Function and one User Procedure, which together provide a means to script...
7
7610
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 session (user) at a time. This is to ensure that the ID numbers are cleanly incremented, and that no...
3
1983
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
1730
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 found that the to balance all the requirements of the system, I needed a schema that could only be...
9
1359
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 DB) I want to display an alert message. I get the error indicated below when I run the page - I...
2
51985
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 to any of the flat file like MS WORD or paint. I want this diagram to be uploaded to one Flat file...
10
2075
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 the project is actually fairly straightforward, but after several meetings, emails and telephone...
0
2132
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. Is there a better way to keep the Database Diagram and DBML Diagram in sync? I would rather not...
0
8732
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8649
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8975
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8933
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6567
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5904
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4410
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3102
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2035
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.