Wednesday, March 7, 2012
DDL
Is there a way to get the Data Definition Library for a
Database? I need to send it to my parent Corporation.
Thanks,
JoeThere are a number of ways to generate the T-SQL code to recreate your
database. Here is an article that might help:
http://www.dbazine.com/larsen4.shtml
--
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe|||Hi,
Ope Enterprise Manager -- Expand the database-- Right click above the
database you need the DDL, Select "Alltasks" and click "Generate SQL Script"
and select options you require and click OK. THis
will generate the DDL script for that database.
You can save this as a .SQL file and send to parent corporation.
Thanks
Hari
MCDBA
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe|||Thank you Gregory,
I know how to generate the SQL Script for a DB. I was
wondering if there was a tool or a process to list all
table relationships, indexes and triggers.
Thanks again,
Joe|||This is a multi-part message in MIME format.
--=_NextPart_000_00DB_01C468C7.F0F8E300
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Have you tried the Database Diagram Wizard. If not this wizard should =be able to build you a picture of all the tables and will drawlines to =represent the foreign key relationships. Is this what you are looking =for? You might also consider looking at the =INFORMATION_SCHEMA.TABLE_CONSTRAINTS view
As far as the triggers are concerned you could use SQL-DMO you could =process thru the table object and then through the trigger collection to =identify all the triggers.
Another option might for both might be to select to script all tables, =but then only select the check boxes that generate triggers and foreign =key constraints.
-- ----=----=--
Need SQL Server Examples check out my website at =http://www.geocities.com/sqlserverexamples
"Joe" <anonymous@.discussions.microsoft.com> wrote in message =news:2bdfe01c468f8$502ed0c0$a501280a@.phx.gbl...
> Thank you Gregory,
> > I know how to generate the SQL Script for a DB. I was > wondering if there was a tool or a process to list all > table relationships, indexes and triggers.
> > Thanks again,
> Joe
--=_NextPart_000_00DB_01C468C7.F0F8E300
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&
Have you tried the Database Diagram =Wizard. If not this wizard should be able to build you a picture of all the =tables and will drawlines to represent the foreign key relationships. Is this =what you are looking for? You might also consider looking at the INFORMATION_SCHEMA.TABLE_CONSTRAINTS view
As far as the triggers are concerned =you could use SQL-DMO you could process thru the table object and then through the =trigger collection to identify all the triggers.
Another option might for both might be =to select to script all tables, but then only select the check boxes that generate =triggers and foreign key constraints.
-- ---=----=--
Need SQL Server Examples check out my =website at http://www.geocities.com/sqlserverexamples
"Joe" wrote in message news:2bdfe01c468f8$502ed0c0$a501280a@.phx.gbl...> Thank you =Gregory,> > I know how to generate the SQL Script for a DB. I was => wondering if there was a tool or a process to list all > table relationships, indexes and triggers.> > Thanks =again,> Joe
--=_NextPart_000_00DB_01C468C7.F0F8E300--|||Thank you very much for this info!
DDL
Is there a way to get the Data Definition Library for a
Database? I need to send it to my parent Corporation.
Thanks,
Joe
There are a number of ways to generate the T-SQL code to recreate your
database. Here is an article that might help:
http://www.dbazine.com/larsen4.shtml
----
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe
|||Hi,
Ope Enterprise Manager -- Expand the database-- Right click above the
database you need the DDL, Select "Alltasks" and click "Generate SQL Script"
and select options you require and click OK. THis
will generate the DDL script for that database.
You can save this as a .SQL file and send to parent corporation.
Thanks
Hari
MCDBA
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe
|||Thank you Gregory,
I know how to generate the SQL Script for a DB. I was
wondering if there was a tool or a process to list all
table relationships, indexes and triggers.
Thanks again,
Joe
|||Have you tried the Database Diagram Wizard. If not this wizard should be able to build you a picture of all the tables and will drawlines to represent the foreign key relationships. Is this what you are looking for? You might also consider looking at the INFORMATION_SCHEMA.TABLE_CONSTRAINTS view
As far as the triggers are concerned you could use SQL-DMO you could process thru the table object and then through the trigger collection to identify all the triggers.
Another option might for both might be to select to script all tables, but then only select the check boxes that generate triggers and foreign key constraints.
-------
Need SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples
"Joe" <anonymous@.discussions.microsoft.com> wrote in message news:2bdfe01c468f8$502ed0c0$a501280a@.phx.gbl...
> Thank you Gregory,
> I know how to generate the SQL Script for a DB. I was
> wondering if there was a tool or a process to list all
> table relationships, indexes and triggers.
> Thanks again,
> Joe
|||Thank you very much for this info!
DDL
Is there a way to get the Data Definition Library for a
Database? I need to send it to my parent Corporation.
Thanks,
JoeThere are a number of ways to generate the T-SQL code to recreate your
database. Here is an article that might help:
http://www.dbazine.com/larsen4.shtml
----
----
--
Need SQL Server Examples check out my website at
http://www.geocities.com/sqlserverexamples
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx
.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe|||Hi,
Ope Enterprise Manager -- Expand the database-- Right click above the
database you need the DDL, Select "Alltasks" and click "Generate SQL Script"
and select options you require and click OK. THis
will generate the DDL script for that database.
You can save this as a .SQL file and send to parent corporation.
Thanks
Hari
MCDBA
"JOE" <anonymous@.discussions.microsoft.com> wrote in message
news:2b68501c468f4$50d93e60$a601280a@.phx
.gbl...
> Hi All,
> Is there a way to get the Data Definition Library for a
> Database? I need to send it to my parent Corporation.
> Thanks,
> Joe|||Thank you Gregory,
I know how to generate the SQL Script for a DB. I was
wondering if there was a tool or a process to list all
table relationships, indexes and triggers.
Thanks again,
Joe|||Have you tried the Database Diagram Wizard. If not this wizard should be ab
le to build you a picture of all the tables and will drawlines to represent
the foreign key relationships. Is this what you are looking for? You might
also consider looking at the INFORMATION_SCHEMA.TABLE_CONSTRAINTS view
As far as the triggers are concerned you could use SQL-DMO you could process
thru the table object and then through the trigger collection to identify a
ll the triggers.
Another option might for both might be to select to script all tables, but t
hen only select the check boxes that generate triggers and foreign key const
raints.
--
----
----
--
Need SQL Server Examples check out my website at http://www.geocities.com/sqlserve
rexamples
"Joe" <anonymous@.discussions.microsoft.com> wrote in message news:2bdfe01c468f8$502ed0c0$a50
1280a@.phx.gbl...
> Thank you Gregory,
>
> I know how to generate the SQL Script for a DB. I was
> wondering if there was a tool or a process to list all
> table relationships, indexes and triggers.
>
> Thanks again,
> Joe|||Thank you very much for this info!
Tuesday, February 14, 2012
DB-LIB and SQL 2005
Hello,
I've an application developped in VC ++ 6.0 using Db library for bulk copying flat files records to a SQL server (SQL server 7) table. We're trying to migrate to MSSQL 2005. While performing tests, the bcp command fails telling that "The primary key constraint has been violated'. All other Db lib command works with no problem. I've even changed the format file (.fmt) in eliminating the Primary key field as well as in the flat file (source file). But the bcp_exec command succeeds with no problem if i delete the primary constraint. Where's the problem with this new version of SQL SERVER 2005 ?
Thanks for your help
Let me see if I understand you correctly.
You have an application that copies a flat file into a SQL Server 2005 table using bcp_exec in the DB-Lib. When trying to do this, you receive the error "The primary key constraint has been violated". If you delete the primary key constraint on the table, bcp_exec then succeeds. Is this correct? Did the table in SQL Server 7 contain the primary key constraint as well but imports worked anyways?
You probably know this, but I'll state it anyways -- primary keys must be unique, including that they cannot be set to NULL. If I understand correctly, simply deleting the columns from the flat file and the format file will not work as that would try to put a default value of NULL in the primary key column, something not allowed.
Does the table in SQL Server 7 already have unique values in this column? If so, I'm surprised that there would be a problem, unless there's a collision with the data already in the table on SQL Server 2005.
I would suggest comparing the schemas. If they are identical, including constraints, then see if there is something amiss in the data, a NULL or something else. If there isn't, then try looking at what's already in the SQL Server 2005 table and compare that to what's in the flat file. Is there a conflict or collision there preventing the import?
If none of these is the case, please reply and we can see what else we can find.
|||Thanks a lot for your reply.
The sql server 7.0 table contains the primary key constraint and the bcp_exec via DB-Lib works fine. The format file references this primary key and in the flat file that column contains 0 for each record. The field separator is ;. The table was created on SQLSERVER 2005 using the same commands as for SQL 7.
CREATE TABLE [dbo].[Table1] (
[Field1] [int] IDENTITY (1, 1) NOT NULL ,
etc
etc...
)
GO
ALTER TABLE [dbo].[Table1] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
[Field1]
) ON [PRIMARY]
GO
As i've explained earlier that when i found that the bcp_exec did'nt work with SQL 2005, i've complety removed the primary key (field1 in our ex.) from the format file and the Zros from the flat file. Nothing doing... this time bcp exec fails with no message.
Thanks a lot again