Showing posts with label engineering. Show all posts
Showing posts with label engineering. Show all posts

Monday, March 12, 2012

Reverse enginnering in VISIO 2002 (problem with sp_primarykey)

I have problem if I want to do reverse engineering in VISIO 2002.
The database uses primary key created with sp_primarykey an foreign keys with sp_foreingnkey

In VISIO - Database - Options - Drivers I had set the DDL script generationas follows:
Preffered version - 6.0
Generate primary key using - sp_primarykey
Generate foregin key using - sp_foreignkey

The process had passed without errors, but the relations didn't showed.
I tried option "Show related tables" but nothing didn't happend.

thanks.That could possibily be because of the loss of dependensies. The happens when you drop and recreate few objects in the database, which does ot re-establish the dependensies.

Try recompiling the objects or establishing the foreign keys again.

Thanks.

Reverse engineering tables

Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
Simon
Simon
Did you mean that ans engineer is a word like 'engineer'?
This script has written by Vyas Kondreddi. See if it helps you.
CREATE PROC SearchAllTables
(
@.SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue
nvarchar(3630))
SET NOCOUNT ON
DECLARE @.TableName nvarchar(256), @.ColumnName nvarchar(128), @.SearchStr2
nvarchar(110)
SET @.TableName = ''
SET @.SearchStr2 = QUOTENAME('%' + @.SearchStr + '%','''')
WHILE @.TableName IS NOT NULL
BEGIN
SET @.ColumnName = ''
SET @.TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @.TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)
WHILE (@.TableName IS NOT NULL) AND (@.ColumnName IS NOT NULL)
BEGIN
SET @.ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@.TableName, 2)
AND TABLE_NAME = PARSENAME(@.TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @.ColumnName
)
IF @.ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @.TableName + '.' + @.ColumnName + ''', LEFT(' +
@.ColumnName + ', 3630)
FROM ' + @.TableName + ' (NOLOCK) ' +
' WHERE ' + @.ColumnName + ' LIKE ' + @.SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
END
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:#dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> Is there anyway to analyse the tables in my database and reverse engineer
> the SQL out of them?
> I really need to SQL quite badly but I can't see any easy way to get it.
> Thanks to anyone who can help
> Simon
>
|||Make use of the scripting functionality available in SQL Server Enterprise
Manager.
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:%23dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
Simon

Reverse engineering tables

Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
SimonSimon
Did you mean that ans engineer is a word like 'engineer'?
This script has written by Vyas Kondreddi. See if it helps you.
CREATE PROC SearchAllTables
(
@.SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue
nvarchar(3630))
SET NOCOUNT ON
DECLARE @.TableName nvarchar(256), @.ColumnName nvarchar(128), @.SearchStr2
nvarchar(110)
SET @.TableName = ''
SET @.SearchStr2 = QUOTENAME('%' + @.SearchStr + '%','''')
WHILE @.TableName IS NOT NULL
BEGIN
SET @.ColumnName = ''
SET @.TableName = (
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @.TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)
WHILE (@.TableName IS NOT NULL) AND (@.ColumnName IS NOT NULL)
BEGIN
SET @.ColumnName = (
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@.TableName, 2)
AND TABLE_NAME = PARSENAME(@.TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @.ColumnName
)
IF @.ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @.TableName + '.' + @.ColumnName + ''', LEFT(' +
@.ColumnName + ', 3630)
FROM ' + @.TableName + ' (NOLOCK) ' +
' WHERE ' + @.ColumnName + ' LIKE ' + @.SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
END
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:#dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> Is there anyway to analyse the tables in my database and reverse engineer
> the SQL out of them?
> I really need to SQL quite badly but I can't see any easy way to get it.
> Thanks to anyone who can help
> Simon
>|||Make use of the scripting functionality available in SQL Server Enterprise
Manager.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:%23dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
Simon

Reverse engineering tables

Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
SimonSimon
Did you mean that ans engineer is a word like 'engineer'?
This script has written by Vyas Kondreddi. See if it helps you.
CREATE PROC SearchAllTables
(
@.SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue
nvarchar(3630))
SET NOCOUNT ON
DECLARE @.TableName nvarchar(256), @.ColumnName nvarchar(128), @.SearchStr2
nvarchar(110)
SET @.TableName = ''
SET @.SearchStr2 = QUOTENAME('%' + @.SearchStr + '%','''')
WHILE @.TableName IS NOT NULL
BEGIN
SET @.ColumnName = ''
SET @.TableName =
(
SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE'
AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @.TableName
AND OBJECTPROPERTY(
OBJECT_ID(
QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
), 'IsMSShipped'
) = 0
)
WHILE (@.TableName IS NOT NULL) AND (@.ColumnName IS NOT NULL)
BEGIN
SET @.ColumnName =
(
SELECT MIN(QUOTENAME(COLUMN_NAME))
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = PARSENAME(@.TableName, 2)
AND TABLE_NAME = PARSENAME(@.TableName, 1)
AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')
AND QUOTENAME(COLUMN_NAME) > @.ColumnName
)
IF @.ColumnName IS NOT NULL
BEGIN
INSERT INTO #Results
EXEC
(
'SELECT ''' + @.TableName + '.' + @.ColumnName + ''', LEFT(' +
@.ColumnName + ', 3630)
FROM ' + @.TableName + ' (NOLOCK) ' +
' WHERE ' + @.ColumnName + ' LIKE ' + @.SearchStr2
)
END
END
END
SELECT ColumnName, ColumnValue FROM #Results
END
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:#dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> Is there anyway to analyse the tables in my database and reverse engineer
> the SQL out of them?
> I really need to SQL quite badly but I can't see any easy way to get it.
> Thanks to anyone who can help
> Simon
>|||Make use of the scripting functionality available in SQL Server Enterprise
Manager.
--
HTH,
Vyas, MVP (SQL Server)
http://vyaskn.tripod.com/
Is .NET important for a database professional?
http://vyaskn.tripod.com/poll.htm
"Simon Harvey" <simon.harvey@.the-web-works.co.uk> wrote in message
news:%23dC6oGRLEHA.2660@.TK2MSFTNGP09.phx.gbl...
Hi all,
Is there anyway to analyse the tables in my database and reverse engineer
the SQL out of them?
I really need to SQL quite badly but I can't see any easy way to get it.
Thanks to anyone who can help
Simon

reverse engineering MS SQL server 2k5

Hi Alan
I can certainly import a database and foreign keys in SQL 2005, for instance
if I choose the northwind database and go through the wizard making sure that
FKs are imported and I choose the option to add the tables later to a
diagram. I can then sekect the customers tables from the tables and views box
and drag it onto the diagram. Then right clicking show related tables will
bring in the orders and customercustomerdemo tables with their foreign keys.
John
"Alain R." wrote:

> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by Visio and its reverse engineering method
> but Visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>
I had that issue also, I installed SP3 for Visio 2003 and it started working
after that . Thanks!
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"John Bell" wrote:
[vbcol=seagreen]
> Hi Alan
> I can certainly import a database and foreign keys in SQL 2005, for instance
> if I choose the northwind database and go through the wizard making sure that
> FKs are imported and I choose the option to add the tables later to a
> diagram. I can then sekect the customers tables from the tables and views box
> and drag it onto the diagram. Then right clicking show related tables will
> bring in the orders and customercustomerdemo tables with their foreign keys.
> John
> "Alain R." wrote:
|||Hi
I was using Microsoft Office Visio for Enterprise Architects (11.7218.8132)
SP2
John
"Mohit K. Gupta" wrote:
[vbcol=seagreen]
> I had that issue also, I installed SP3 for Visio 2003 and it started working
> after that . Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
>
> "John Bell" wrote:

reverse engineering MS SQL server 2k5

Hi,
I got a DB with more than 100 tables.
i tried to get it structure by Visio and its reverse engineering method
but Visio does not draw "links" among tables representing PK and FK
connections.
So do you know any other software which could do the job ?
maybe a simple freeware is enough, it is just to have an overview on
this database and its objects.
thanks a lot,
A.Hi Alain
Visio should import these links (at least it did in SQL 2000!) Usually I
import the structure and then draw drag what is required onto a diagrams
rather than importing them directly onto diagram.
John
"Alain R." wrote:
> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by Visio and its reverse engineering method
> but Visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||If you just want to have an overview on the database and its objects, would
the existing "Database Diagrams" feature in SQL Server 2005 be good enough
for you?
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Alain R." wrote:
> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by Visio and its reverse engineering method
> but Visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||Hi Alan
I can certainly import a database and foreign keys in SQL 2005, for instance
if I choose the northwind database and go through the wizard making sure that
FKs are imported and I choose the option to add the tables later to a
diagram. I can then sekect the customers tables from the tables and views box
and drag it onto the diagram. Then right clicking show related tables will
bring in the orders and customercustomerdemo tables with their foreign keys.
John
"Alain R." wrote:
> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by Visio and its reverse engineering method
> but Visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||I had that issue also, I installed SP3 for Visio 2003 and it started working
after that :). Thanks!
--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"John Bell" wrote:
> Hi Alan
> I can certainly import a database and foreign keys in SQL 2005, for instance
> if I choose the northwind database and go through the wizard making sure that
> FKs are imported and I choose the option to add the tables later to a
> diagram. I can then sekect the customers tables from the tables and views box
> and drag it onto the diagram. Then right clicking show related tables will
> bring in the orders and customercustomerdemo tables with their foreign keys.
> John
> "Alain R." wrote:
> > Hi,
> >
> > I got a DB with more than 100 tables.
> > i tried to get it structure by Visio and its reverse engineering method
> > but Visio does not draw "links" among tables representing PK and FK
> > connections.
> >
> > So do you know any other software which could do the job ?
> > maybe a simple freeware is enough, it is just to have an overview on
> > this database and its objects.
> >
> > thanks a lot,
> >
> > A.
> >|||Hi
I was using Microsoft Office Visio for Enterprise Architects (11.7218.8132)
SP2
John
"Mohit K. Gupta" wrote:
> I had that issue also, I installed SP3 for Visio 2003 and it started working
> after that :). Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
>
> "John Bell" wrote:
> > Hi Alan
> >
> > I can certainly import a database and foreign keys in SQL 2005, for instance
> > if I choose the northwind database and go through the wizard making sure that
> > FKs are imported and I choose the option to add the tables later to a
> > diagram. I can then sekect the customers tables from the tables and views box
> > and drag it onto the diagram. Then right clicking show related tables will
> > bring in the orders and customercustomerdemo tables with their foreign keys.
> >
> > John
> >
> > "Alain R." wrote:
> >
> > > Hi,
> > >
> > > I got a DB with more than 100 tables.
> > > i tried to get it structure by Visio and its reverse engineering method
> > > but Visio does not draw "links" among tables representing PK and FK
> > > connections.
> > >
> > > So do you know any other software which could do the job ?
> > > maybe a simple freeware is enough, it is just to have an overview on
> > > this database and its objects.
> > >
> > > thanks a lot,
> > >
> > > A.
> > >

reverse engineering MS SQL server 2k5

Hi,
I got a DB with more than 100 tables.
i tried to get it structure by visio and its reverse engineering method
but visio does not draw "links" among tables representing PK and FK
connections.
So do you know any other software which could do the job ?
maybe a simple freeware is enough, it is just to have an overview on
this database and its objects.
thanks a lot,
A.Hi Alain
Visio should import these links (at least it did in SQL 2000!) Usually I
import the structure and then draw drag what is required onto a diagrams
rather than importing them directly onto diagram.
John
"Alain R." wrote:

> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by visio and its reverse engineering method
> but visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||If you just want to have an overview on the database and its objects, would
the existing "Database Diagrams" feature in SQL Server 2005 be good enough
for you?
Ben Nevarez
Senior Database Administrator
AIG SunAmerica
"Alain R." wrote:

> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by visio and its reverse engineering method
> but visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||Hi Alan
I can certainly import a database and foreign keys in SQL 2005, for instance
if I choose the northwind database and go through the wizard making sure tha
t
FKs are imported and I choose the option to add the tables later to a
diagram. I can then sekect the customers tables from the tables and views bo
x
and drag it onto the diagram. Then right clicking show related tables will
bring in the orders and customercustomerdemo tables with their foreign keys.
John
"Alain R." wrote:

> Hi,
> I got a DB with more than 100 tables.
> i tried to get it structure by visio and its reverse engineering method
> but visio does not draw "links" among tables representing PK and FK
> connections.
> So do you know any other software which could do the job ?
> maybe a simple freeware is enough, it is just to have an overview on
> this database and its objects.
> thanks a lot,
> A.
>|||I had that issue also, I installed SP3 for visio 2003 and it started working
after that . Thanks!
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"John Bell" wrote:
[vbcol=seagreen]
> Hi Alan
> I can certainly import a database and foreign keys in SQL 2005, for instan
ce
> if I choose the northwind database and go through the wizard making sure t
hat
> FKs are imported and I choose the option to add the tables later to a
> diagram. I can then sekect the customers tables from the tables and views
box
> and drag it onto the diagram. Then right clicking show related tables will
> bring in the orders and customercustomerdemo tables with their foreign key
s.
> John
> "Alain R." wrote:
>|||Hi
I was using Microsoft Office visio for Enterprise Architects (11.7218.8132)
SP2
John
"Mohit K. Gupta" wrote:
[vbcol=seagreen]
> I had that issue also, I installed SP3 for visio 2003 and it started worki
ng
> after that . Thanks!
> --
> Mohit K. Gupta
> B.Sc. CS, Minor Japanese
> MCTS: SQL Server 2005
>
> "John Bell" wrote:
>

Reverse Engineering - FK

Hi there --
Can some one clue me in about Foriegn Keys and how I can determine what they
are.
I'm trying to reverse engineer a DB and I see some fields that have
interesting values. And these coumns do not appear to be in the table when I
select * from
The values I see are ...
=(1ABF96C75BA790
=G312296BA577411
$0000960D431B939
Do any these look like they are foriegn keys? And if so, how can I confirm?
Thanks
Mark,
Use sp_help tablename - where tablename is the table in question.
HTH
Jerry
"X-Mark" <X-Mark@.discussions.microsoft.com> wrote in message
news:2EFD8862-0E4B-42AB-882F-ECA69DC484E5@.microsoft.com...
> Hi there --
> Can some one clue me in about Foriegn Keys and how I can determine what
> they
> are.
> I'm trying to reverse engineer a DB and I see some fields that have
> interesting values. And these coumns do not appear to be in the table
> when I
> select * from
> The values I see are ...
> =(1ABF96C75BA790
> =G312296BA577411
> $0000960D431B939
> Do any these look like they are foriegn keys? And if so, how can I
> confirm?
> Thanks

Reverse Engineering - FK

Hi there --
Can some one clue me in about Foriegn Keys and how I can determine what they
are.
I'm trying to reverse engineer a DB and I see some fields that have
interesting values. And these coumns do not appear to be in the table when
I
select * from
The values I see are ...
=(1ABF96C75BA790
=G312296BA577411
$0000960D431B939
Do any these look like they are foriegn keys? And if so, how can I confirm?
ThanksMark,
Use sp_help tablename - where tablename is the table in question.
HTH
Jerry
"X-Mark" <X-Mark@.discussions.microsoft.com> wrote in message
news:2EFD8862-0E4B-42AB-882F-ECA69DC484E5@.microsoft.com...
> Hi there --
> Can some one clue me in about Foriegn Keys and how I can determine what
> they
> are.
> I'm trying to reverse engineer a DB and I see some fields that have
> interesting values. And these coumns do not appear to be in the table
> when I
> select * from
> The values I see are ...
> =(1ABF96C75BA790
> =G312296BA577411
> $0000960D431B939
> Do any these look like they are foriegn keys? And if so, how can I
> confirm?
> Thanks

Reverse Engineering - FK

Hi there --
Can some one clue me in about Foriegn Keys and how I can determine what they
are.
I'm trying to reverse engineer a DB and I see some fields that have
interesting values. And these coumns do not appear to be in the table when I
select * from
The values I see are ...
=(1ABF96C75BA790
=G312296BA577411
$0000960D431B939
Do any these look like they are foriegn keys? And if so, how can I confirm?
ThanksMark,
Use sp_help tablename - where tablename is the table in question.
HTH
Jerry
"X-Mark" <X-Mark@.discussions.microsoft.com> wrote in message
news:2EFD8862-0E4B-42AB-882F-ECA69DC484E5@.microsoft.com...
> Hi there --
> Can some one clue me in about Foriegn Keys and how I can determine what
> they
> are.
> I'm trying to reverse engineer a DB and I see some fields that have
> interesting values. And these coumns do not appear to be in the table
> when I
> select * from
> The values I see are ...
> =(1ABF96C75BA790
> =G312296BA577411
> $0000960D431B939
> Do any these look like they are foriegn keys? And if so, how can I
> confirm?
> Thanks