Showing posts with label keys. Show all posts
Showing posts with label keys. Show all posts

Friday, March 30, 2012

Modify column order

Hello,
I currently have a table with 2 primary keys, and 6
columsn following that. I want to add 2 new columns, that
will also be primary keys. I want to insert these new
columns in position 3 and 4.
Is there a way to do this without dropping the table and
recreating it in the correct column order ?
eg:
Table : dbo.TMCLASS has columns as follows
COUNTRYCODE (pk)
CLASS (pk)
EFFECTIVEDATE
GOODSSERVICES
INTERNATIONALCLASS
ASSOCIATEDCLASSES
CLASSHEADING
CLASSNOTES
PROPERTYTYPE
I want a new structure (PROPERTYTYE and SEQUENCENO added)
Table : dbo.TMCLASS
COUNTRYCODE (pk)
CLASS (pk)
PROPERTYTYPE (pk)
SEQUENCENO (pk)
EFFECTIVEDATE
GOODSSERVICES
INTERNATIONALCLASS
ASSOCIATEDCLASSES
CLASSHEADING
CLASSNOTES
PROPERTYTYPE
I am tryign to avoid dropping and recreating the table as
there is data at client sites.
Thanks,
AlisonDon't think so. I also don't know why you would want to. I see a few
people asking for this aesthetic change. If you qualify all your statements
instead of using * then column order is irrelevant. May look prettier in EM
or other tool but that is about it I thnk.
--
--
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"Alison Bell" <abell@.cpaglobal.com> wrote in message
news:047f01c36552$898f9d40$a601280a@.phx.gbl...
> Hello,
> I currently have a table with 2 primary keys, and 6
> columsn following that. I want to add 2 new columns, that
> will also be primary keys. I want to insert these new
> columns in position 3 and 4.
> Is there a way to do this without dropping the table and
> recreating it in the correct column order ?
> eg:
> Table : dbo.TMCLASS has columns as follows
> COUNTRYCODE (pk)
> CLASS (pk)
> EFFECTIVEDATE
> GOODSSERVICES
> INTERNATIONALCLASS
> ASSOCIATEDCLASSES
> CLASSHEADING
> CLASSNOTES
> PROPERTYTYPE
> I want a new structure (PROPERTYTYE and SEQUENCENO added)
> Table : dbo.TMCLASS
> COUNTRYCODE (pk)
> CLASS (pk)
> PROPERTYTYPE (pk)
> SEQUENCENO (pk)
> EFFECTIVEDATE
> GOODSSERVICES
> INTERNATIONALCLASS
> ASSOCIATEDCLASSES
> CLASSHEADING
> CLASSNOTES
> PROPERTYTYPE
> I am tryign to avoid dropping and recreating the table as
> there is data at client sites.
> Thanks,
> Alison
>|||I don't think there is a way either. Reason for wanting
the specific order is to match "alltables" script
generated by ERwin for data transfer at a later date. It
just means modifying the generated script each time we
make a DB change, as ERwin places the columns in pos 3
and 4 (non modifyable).
Thanks,
Alison
>--Original Message--
>Don't think so. I also don't know why you would want
to. I see a few
>people asking for this aesthetic change. If you qualify
all your statements
>instead of using * then column order is irrelevant. May
look prettier in EM
>or other tool but that is about it I thnk.|||Problem being I must do this via SQL scripting. It is
part of an upgrade script being shipped to client sites.
>--Original Message--
>easiest way is use EM's (pet's tool) table designer. Sql
>2000 will drop and create with your requirements. You
>don't have to do anything.
>>--Original Message--
>>I don't think there is a way either. Reason for
wanting
>>the specific order is to match "alltables" script
>>generated by ERwin for data transfer at a later date.
It
>>just means modifying the generated script each time we
>>make a DB change, as ERwin places the columns in pos 3
>>and 4 (non modifyable).
>>Thanks,
>>Alison
>>--Original Message--
>>Don't think so. I also don't know why you would want
>>to. I see a few
>>people asking for this aesthetic change. If you
qualify
>>all your statements
>>instead of using * then column order is irrelevant.
May
>>look prettier in EM
>>or other tool but that is about it I thnk.
>>.
>.
>|||Then you have to re-create the table (this is what EM does under covers anyhow). There is no
functionality in TSQL (or ANSI SQL, as I remember) to change column order.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Alison Bell" <abell@.cpaglobal.com> wrote in message news:0fe901c366bd$edc2e210$a001280a@.phx.gbl...
> Problem being I must do this via SQL scripting. It is
> part of an upgrade script being shipped to client sites.
> >--Original Message--
> >easiest way is use EM's (pet's tool) table designer. Sql
> >2000 will drop and create with your requirements. You
> >don't have to do anything.
> >
> >>--Original Message--
> >>I don't think there is a way either. Reason for
> wanting
> >>the specific order is to match "alltables" script
> >>generated by ERwin for data transfer at a later date.
> It
> >>just means modifying the generated script each time we
> >>make a DB change, as ERwin places the columns in pos 3
> >>and 4 (non modifyable).
> >>
> >>Thanks,
> >>Alison
> >>
> >>--Original Message--
> >>Don't think so. I also don't know why you would want
> >>to. I see a few
> >>people asking for this aesthetic change. If you
> qualify
> >>all your statements
> >>instead of using * then column order is irrelevant.
> May
> >>look prettier in EM
> >>or other tool but that is about it I thnk.
> >>
> >>.
> >>
> >.
> >

Wednesday, March 28, 2012

Model definitions

I've inherited a database from a vendor. This database has primary keys defined but not any foreign keys to other tables. The vendor establishes all their relationships in their code.

I've created a simple model off of the base tables, but can only report on one table at a time which makes perfect sense. What is the best way to create a more usable model?

Create views with foreign keys defined and then use the views as my source for the dsv? or can I define relationships within the model itself? I have not been able to figure out how to add a foreign key in the model Can this be done?

1. Load your model into Model Designer.
2. Edit DSV - manually add foreign keys your tables
3. Regen the model - roles should automatically appear.

Wednesday, March 7, 2012

Missing Primary Keys

HI Folks ,

I have a problem with the primary keys in my main Db , I want to setup replication and looks like someone tampered with my database by removing the primary keys.and in order to setup replication i need this table to have primary keys .THere are duplicates in that table but they are nessecary...and for this reason the primary keys do not want to "stick" when i try and specify them.Can anybody help

BurnerWithout the PK, transactional replication won't work. You could use snapshot replication if you wanted.

If your table needs to have duplicate primary keys, you have a design problem. At some point, you'll probably need to fix it.

-PatP|||Hi pat ,

I know taht it wont work. What I want to know is ; is there a way to "restore" the primary keys ?What i did now was create another table with the exact same design ..specified my primary keys..but what i want to do now is import all my data into this table including my duplicates ..is there a way to do this ...using a script or something ..cause dts will not allow duplicates to be importing because of the primary key set on the table .|||I'm confused. I think that you wnat ALTER TABLE ADD CONSTRAINT if you want to put the PK constraint back on the table.

If you are trying to clean out the table, you can use:SELECT *
FROM icky_table AS a
WHERE 1 < (SELECT Count(*)
FROM icky_table AS b
WHERE b.PK = a.PK)This will show you the duplicate rows based on the PK values. You'll have to sort out which of those rows you want to keep and which you want to discard.

-PatP

Saturday, February 25, 2012

Missing Keys & Relationships

(Cross posted to the active server pages listserv at 15Seconds.com)
A few weeks ago I posted a message about keys and relationships that
mysteriously disappeared on our production SQL Server 2000 database. I
managed to restore all of the missing attributes with success. But it
happened again this morning
How can all of the keys and relationships in my database be wiped out in one
deft move? Is there anything in the Master database or elsewhere that could
cause everything to disappear at once?
The system administrator is not a DBA, so human-error is definitely a
possibility. They are going to blame the scripts that are used to update
the stored procedures, but the same scripts are tested on our test
deployment server and work flawlessly. The scripts contained no changes to
database tables - they strictly updated stored procedures.
Thanks for your help.
DaveThis is a multi-part message in MIME format.
--=_NextPart_000_02E7_01C36018.E9B80A20
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Is it possible that some sort of scheduled process executes a script to =drop all constraints?
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
(Cross posted to the active server pages listserv at 15Seconds.com)
A few weeks ago I posted a message about keys and relationships that
mysteriously disappeared on our production SQL Server 2000 database. I
managed to restore all of the missing attributes with success. But it
happened again this morning
How can all of the keys and relationships in my database be wiped out in =one
deft move? Is there anything in the Master database or elsewhere that =could
cause everything to disappear at once?
The system administrator is not a DBA, so human-error is definitely a
possibility. They are going to blame the scripts that are used to =update
the stored procedures, but the same scripts are tested on our test
deployment server and work flawlessly. The scripts contained no changes =to
database tables - they strictly updated stored procedures.
Thanks for your help.
Dave
--=_NextPart_000_02E7_01C36018.E9B80A20
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Is it possible that some sort of =scheduled process executes a script to drop all constraints?
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Dave" wrote in message news:eskCToDYDHA.2484=@.TK2MSFTNGP09.phx.gbl...(Cross posted to the active server pages listserv at 15Seconds.com)A =few weeks ago I posted a message about keys and relationships thatmysteriously =disappeared on our production SQL Server 2000 database. =Imanaged to restore all of the missing attributes with success. But ithappened =again this morningHow can all of the keys and relationships in my =database be wiped out in onedeft move? Is there anything in the Master =database or elsewhere that couldcause everything to disappear at =once?The system administrator is not a DBA, so human-error is definitely =apossibility. They are going to blame the scripts that are used to updatethe =stored procedures, but the same scripts are tested on our testdeployment =server and work flawlessly. The scripts contained no changes todatabase =tables - they strictly updated stored procedures.Thanks for your help.Dave

--=_NextPart_000_02E7_01C36018.E9B80A20--|||The data definitions didn't change, so there was no move during this time.
What we did the first time when they all disapeared was to detach the
database (jsut the database, not Master). Then I attached it on the
developmet server, updated the keys, detached it and reattached it to the
production database.
Today we updated some stored procedures, and the script we used was
generated by SQL Server. It's pretty standard: drops the stored procedures
if they exist and then re/create them. Simple stuff, really, so I'm not
convinced it is our script. I haven't totally ruled it out, but I would
guess it's not my script.
Dave
"Allan Mitchell" <allan@.no-spam.sqldts.com> wrote in message
news:u5snHqDYDHA.416@.tk2msftngp13.phx.gbl...
> How are you moving the data/definitions?
> From what to what?
> It certainly should not miss anything out especially if you are using the
exact same script on another server and it works fine.
>
> --
> Allan Mitchell (Microsoft SQL Server MVP)
> MCSE,MCDBA
> www.SQLDTS.com
> I support PASS - the definitive, global community
> for SQL Server professionals - http://www.sqlpass.org|||This is a multi-part message in MIME format.
--=_NextPart_000_030E_01C3601A.4BFC0690
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
No. To drop constraints takes a deliberate act and to drop them all =would require some sort of script. I'd be curious if there was a stored =proc in your database that does this. If you want to be absolutely =certain of when this happens, I'd use the profiler.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:OVaposDYDHA.1644@.TK2MSFTNGP10.phx.gbl...
I sure hope not because it's not anything I configured.
Are there any SQL defaults that might mimic this?
Dave
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eRRZfqDYDHA.2256@.TK2MSFTNGP10.phx.gbl...
Is it possible that some sort of scheduled process executes a script =to drop all constraints?
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
(Cross posted to the active server pages listserv at 15Seconds.com)
A few weeks ago I posted a message about keys and relationships that
mysteriously disappeared on our production SQL Server 2000 database. =I
managed to restore all of the missing attributes with success. But it
happened again this morning
How can all of the keys and relationships in my database be wiped out =in one
deft move? Is there anything in the Master database or elsewhere that =could
cause everything to disappear at once?
The system administrator is not a DBA, so human-error is definitely a
possibility. They are going to blame the scripts that are used to =update
the stored procedures, but the same scripts are tested on our test
deployment server and work flawlessly. The scripts contained no =changes to
database tables - they strictly updated stored procedures.
Thanks for your help.
Dave
--=_NextPart_000_030E_01C3601A.4BFC0690
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

No. To drop constraints takes a =deliberate act and to drop them all would require some sort of script. I'd be =curious if there was a stored proc in your database that does this. If you =want to be absolutely certain of when this happens, I'd use the =profiler.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Dave" wrote in message news:OVaposDYDHA.1644=@.TK2MSFTNGP10.phx.gbl...
I sure hope not because it's not =anything I configured.
Are there any SQL defaults that might =mimic this?
Dave
"Tom Moreau" = wrote in message news:eRRZfqDYDHA.2256=@.TK2MSFTNGP10.phx.gbl...
Is it possible that some sort of =scheduled process executes a script to drop all constraints?
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Dave" wrote =in message news:eskCToDYDHA.2484=@.TK2MSFTNGP09.phx.gbl...(Cross posted to the active server pages listserv at 15Seconds.com)A =few weeks ago I posted a message about keys and relationships =thatmysteriously disappeared on our production SQL Server 2000 database. =Imanaged to restore all of the missing attributes with success. But ithappened =again this morningHow can all of the keys and relationships in my =database be wiped out in onedeft move? Is there anything in the =Master database or elsewhere that couldcause everything to disappear at once?The system administrator is not a DBA, so human-error is definitely apossibility. They are going to blame the scripts =that are used to updatethe stored procedures, but the same scripts are =tested on our testdeployment server and work flawlessly. The =scripts contained no changes todatabase tables - they strictly updated =stored procedures.Thanks for your help.Dave

--=_NextPart_000_030E_01C3601A.4BFC0690--|||This is a multi-part message in MIME format.
--=_NextPart_000_0036_01C3601B.602B9BC0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
That's what I thought - that deleting these constraints is a chore and =can't really happen "accidentally"
Once, our script was accidentally run against the master database and =ended up creating a bunch of unncessary stored procedures. I know that =the system admin went to clean that out, and I was wondering if she =touched some other thing in the process and that something in the master =database is now causing this behavior.
I keep thinking it's accidental, but, if it were intentional, how would =this get done?
Is there any way to retroactively figure out exactly when this happend?
Thanks for all of your help, Tom
Dave
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eNjQZvDYDHA.536@.TK2MSFTNGP10.phx.gbl...
No. To drop constraints takes a deliberate act and to drop them all =would require some sort of script. I'd be curious if there was a stored =proc in your database that does this. If you want to be absolutely =certain of when this happens, I'd use the profiler.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:OVaposDYDHA.1644@.TK2MSFTNGP10.phx.gbl...
I sure hope not because it's not anything I configured.
Are there any SQL defaults that might mimic this?
Dave
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eRRZfqDYDHA.2256@.TK2MSFTNGP10.phx.gbl...
Is it possible that some sort of scheduled process executes a script =to drop all constraints?
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
(Cross posted to the active server pages listserv at 15Seconds.com)
A few weeks ago I posted a message about keys and relationships that
mysteriously disappeared on our production SQL Server 2000 database. = I
managed to restore all of the missing attributes with success. But =it
happened again this morning
How can all of the keys and relationships in my database be wiped =out in one
deft move? Is there anything in the Master database or elsewhere =that could
cause everything to disappear at once?
The system administrator is not a DBA, so human-error is definitely =a
possibility. They are going to blame the scripts that are used to =update
the stored procedures, but the same scripts are tested on our test
deployment server and work flawlessly. The scripts contained no =changes to
database tables - they strictly updated stored procedures.
Thanks for your help.
Dave
--=_NextPart_000_0036_01C3601B.602B9BC0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT face=3DArial size=3D2>That's what I thought - that deleting =these constraints is a chore and can't really happen ="accidentally"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Once, our script was accidentally run =against the master database and ended up creating a bunch of unncessary stored procedures. I know that the system admin went to clean that out, =and I was wondering if she touched some other thing in the process and that =something in the master database is now causing this behavior.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I keep thinking it's accidental, but, =if it were intentional, how would this get done?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Is there any way to retroactively =figure out exactly when this happend?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for all of your help, =Tom</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Tom Moreau" <<A =href=3D"mailto:tom@.dont.spam.me.cips.ca">tom@.dont.spam.me.cips.ca</A>>= wrote in message <A =href=3D"news:eNjQZvDYDHA.536@.TK2MSFTNGP10.phx.gbl">news:eNjQZvDYDHA.536@.T=K2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>No. To drop constraints takes =a deliberate act and to drop them all would require some sort of script. I'd =be curious if there was a stored proc in your database that does =this. If you want to be absolutely certain of when this happens, I'd use the profiler.</FONT></DIV>
<DIV><BR>-- <BR>Tom</DIV>
<DIV> </DIV>
=<DIV>---<BR>T=homas A. Moreau, BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL =Server Professional<BR>Toronto, ON Canada<BR><A =href=3D"www.pinnaclepublishing.com=">http://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=
/sql</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>"Dave" <<A href=3D"mailto:dave@.glimmernet.com">dave@.glimmernet.com</A>> wrote =in message <A =href=3D"news:OVaposDYDHA.1644@.TK2MSFTNGP10.phx.gbl">news:OVaposDYDHA.1644=@.TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I sure hope not because it's not =anything I configured.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Are there any SQL defaults that might =mimic this?</FONT><FONT face=3DArial size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Tom Moreau" <<A =href=3D"mailto:tom@.dont.spam.me.cips.ca">tom@.dont.spam.me.cips.ca</A>>= wrote in message <A =href=3D"news:eRRZfqDYDHA.2256@.TK2MSFTNGP10.phx.gbl">news:eRRZfqDYDHA.2256=@.TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>Is it possible that some sort of =scheduled process executes a script to drop all constraints?</FONT></DIV>
<DIV><BR>-- <BR>Tom</DIV>
<DIV> </DIV>
=<DIV>---<BR>T=homas A. Moreau, BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL =Server Professional<BR>Toronto, ON Canada<BR><A =href=3D"www.pinnaclepublishing.com=">http://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=
/sql</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>"Dave" <<A href=3D"mailto:dave@.glimmernet.com">dave@.glimmernet.com</A>> =wrote in message <A =href=3D"news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl">news:eskCToDYDHA.2484=@.TK2MSFTNGP09.phx.gbl</A>...</DIV>(Cross posted to the active server pages listserv at =15Seconds.com)<BR><BR>A few weeks ago I posted a message about keys and relationships that<BR>mysteriously disappeared on our production SQL Server 2000 database. I<BR>managed to restore all of the missing =attributes with success. But it<BR>happened again this morning<BR><BR>How can all of =the keys and relationships in my database be wiped out in one<BR>deft move? Is there anything in the Master database or elsewhere =that could<BR>cause everything to disappear at once?<BR><BR>The system administrator is not a DBA, so human-error is definitely a<BR>possibility. They are going to blame the scripts that are =used to update<BR>the stored procedures, but the same scripts are tested on =our test<BR>deployment server and work flawlessly. The scripts =contained no changes to<BR>database tables - they strictly updated stored procedures.<BR><BR>Thanks for your =help.<BR><BR>Dave<BR><BR><BR><BR><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></H=TML>
--=_NextPart_000_0036_01C3601B.602B9BC0--|||OK
detaching the DB is sound.
Attach is sound
To this point here there most definitley will not be key losses.
By Updated the keys do you mean ?
EXEC sp_UPDATESTATS
I would profiler the drop procs script or read it very carefully
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org|||This is a multi-part message in MIME format.
--=_NextPart_000_0346_01C3601D.559545B0
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
You may be able to find out by using Lumigent's Log Explorer - =www.lumigent.com - although I don't know if it tracks constraint =removal. To add to Allan's comments, I'd search through your scripts =for the phase 'drop constraint'.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:OTsepzDYDHA.1492@.TK2MSFTNGP12.phx.gbl...
That's what I thought - that deleting these constraints is a chore and =can't really happen "accidentally"
Once, our script was accidentally run against the master database and =ended up creating a bunch of unncessary stored procedures. I know that =the system admin went to clean that out, and I was wondering if she =touched some other thing in the process and that something in the master =database is now causing this behavior.
I keep thinking it's accidental, but, if it were intentional, how would =this get done?
Is there any way to retroactively figure out exactly when this happend?
Thanks for all of your help, Tom
Dave
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eNjQZvDYDHA.536@.TK2MSFTNGP10.phx.gbl...
No. To drop constraints takes a deliberate act and to drop them all =would require some sort of script. I'd be curious if there was a stored =proc in your database that does this. If you want to be absolutely =certain of when this happens, I'd use the profiler.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:OVaposDYDHA.1644@.TK2MSFTNGP10.phx.gbl...
I sure hope not because it's not anything I configured.
Are there any SQL defaults that might mimic this?
Dave
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eRRZfqDYDHA.2256@.TK2MSFTNGP10.phx.gbl...
Is it possible that some sort of scheduled process executes a script =to drop all constraints?
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
(Cross posted to the active server pages listserv at 15Seconds.com)
A few weeks ago I posted a message about keys and relationships that
mysteriously disappeared on our production SQL Server 2000 database. = I
managed to restore all of the missing attributes with success. But =it
happened again this morning
How can all of the keys and relationships in my database be wiped =out in one
deft move? Is there anything in the Master database or elsewhere =that could
cause everything to disappear at once?
The system administrator is not a DBA, so human-error is definitely =a
possibility. They are going to blame the scripts that are used to =update
the stored procedures, but the same scripts are tested on our test
deployment server and work flawlessly. The scripts contained no =changes to
database tables - they strictly updated stored procedures.
Thanks for your help.
Dave
--=_NextPart_000_0346_01C3601D.559545B0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT face=3DTahoma size=3D2>You may be able to find out by using =Lumigent's Log Explorer - <A href=3D"www.lumigent.com</A>">http://www.lumigent.com">www.lumigent.com</A> =- although I don't know if it tracks constraint removal. To add to Allan's =comments, I'd search through your scripts for the phase 'drop =constraint'.</FONT></DIV>
<DIV><BR>-- <BR>Tom</DIV>
<DIV> </DIV>
<DIV>---<BR>T=homas A. Moreau, BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL =Server Professional<BR>Toronto, ON Canada<BR><A href=3D"www.pinnaclepublishing.com=">http://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=
/sql</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>"Dave" <<A =href=3D"mailto:dave@.glimmernet.com">dave@.glimmernet.com</A>> wrote in message <A href=3D"news:OTsepzDYDHA.1492@.TK2MSFTNGP12.phx.gbl">news:OTsepzDYDHA.1492=@.TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>That's what I thought - that deleting =these constraints is a chore and can't really happen ="accidentally"</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Once, our script was accidentally run =against the master database and ended up creating a bunch of unncessary stored procedures. I know that the system admin went to clean that out, =and I was wondering if she touched some other thing in the process and that =something in the master database is now causing this behavior.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I keep thinking it's accidental, but, =if it were intentional, how would this get done?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Is there any way to retroactively =figure out exactly when this happend?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for all of your help, =Tom</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Tom Moreau" <<A =href=3D"mailto:tom@.dont.spam.me.cips.ca">tom@.dont.spam.me.cips.ca</A>>= wrote in message <A =href=3D"news:eNjQZvDYDHA.536@.TK2MSFTNGP10.phx.gbl">news:eNjQZvDYDHA.536@.T=K2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>No. To drop constraints takes =a deliberate act and to drop them all would require some sort of script. I'd =be curious if there was a stored proc in your database that does =this. If you want to be absolutely certain of when this happens, I'd use the profiler.</FONT></DIV>
<DIV><BR>-- <BR>Tom</DIV>
<DIV> </DIV>
=<DIV>---<BR>T=homas A. Moreau, BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL =Server Professional<BR>Toronto, ON Canada<BR><A =href=3D"www.pinnaclepublishing.com=">http://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=
/sql</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>"Dave" <<A href=3D"mailto:dave@.glimmernet.com">dave@.glimmernet.com</A>> wrote =in message <A =href=3D"news:OVaposDYDHA.1644@.TK2MSFTNGP10.phx.gbl">news:OVaposDYDHA.1644=@.TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>I sure hope not because it's not =anything I configured.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Are there any SQL defaults that might =mimic this?</FONT><FONT face=3DArial size=3D2></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></DIV>
<BLOCKQUOTE style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Tom Moreau" <<A =href=3D"mailto:tom@.dont.spam.me.cips.ca">tom@.dont.spam.me.cips.ca</A>>= wrote in message <A =href=3D"news:eRRZfqDYDHA.2256@.TK2MSFTNGP10.phx.gbl">news:eRRZfqDYDHA.2256=@.TK2MSFTNGP10.phx.gbl</A>...</DIV>
<DIV><FONT face=3DTahoma size=3D2>Is it possible that some sort of =scheduled process executes a script to drop all constraints?</FONT></DIV>
<DIV><BR>-- <BR>Tom</DIV>
<DIV> </DIV>
=<DIV>---<BR>T=homas A. Moreau, BSc, PhD, MCSE, MCDBA<BR>SQL Server MVP<BR>Columnist, SQL =Server Professional<BR>Toronto, ON Canada<BR><A =href=3D"www.pinnaclepublishing.com=">http://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=
/sql</A></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>"Dave" <<A href=3D"mailto:dave@.glimmernet.com">dave@.glimmernet.com</A>> =wrote in message <A =href=3D"news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl">news:eskCToDYDHA.2484=@.TK2MSFTNGP09.phx.gbl</A>...</DIV>(Cross posted to the active server pages listserv at =15Seconds.com)<BR><BR>A few weeks ago I posted a message about keys and relationships that<BR>mysteriously disappeared on our production SQL Server 2000 database. I<BR>managed to restore all of the missing =attributes with success. But it<BR>happened again this morning<BR><BR>How can all of =the keys and relationships in my database be wiped out in one<BR>deft move? Is there anything in the Master database or elsewhere =that could<BR>cause everything to disappear at once?<BR><BR>The system administrator is not a DBA, so human-error is definitely a<BR>possibility. They are going to blame the scripts that are =used to update<BR>the stored procedures, but the same scripts are tested on =our test<BR>deployment server and work flawlessly. The scripts =contained no changes to<BR>database tables - they strictly updated stored procedures.<BR><BR>Thanks for your =help.<BR><BR>Dave<BR><BR><BR><BR><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></H=TML>
--=_NextPart_000_0346_01C3601D.559545B0--|||Well, this problem has been resolved.
The one deft move: apparently the system admin detached the database and
reattached an old version...
I can't win.
But thanks to everyone who helped out. I still have no idea what happened
to the constraints the first time, but it's working now so that's all I can
ask for.
Dave
"Dave" <dave@.glimmernet.com> wrote in message
news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
> (Cross posted to the active server pages listserv at 15Seconds.com)
> A few weeks ago I posted a message about keys and relationships that
> mysteriously disappeared on our production SQL Server 2000 database. I
> managed to restore all of the missing attributes with success. But it
> happened again this morning
> How can all of the keys and relationships in my database be wiped out in
one
> deft move? Is there anything in the Master database or elsewhere that
could
> cause everything to disappear at once?
> The system administrator is not a DBA, so human-error is definitely a
> possibility. They are going to blame the scripts that are used to update
> the stored procedures, but the same scripts are tested on our test
> deployment server and work flawlessly. The scripts contained no changes
to
> database tables - they strictly updated stored procedures.
> Thanks for your help.
> Dave
>
>
>|||This is a multi-part message in MIME format.
--=_NextPart_000_038D_01C36020.23BE9B60
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Looks like she owes you lunch. No ... wait ... she owes us lunch. Make =mine medium rare ... with a baked potato. ;-)
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Dave" <dave@.glimmernet.com> wrote in message =news:uSYgT8DYDHA.1492@.TK2MSFTNGP12.phx.gbl...
Well, this problem has been resolved.
The one deft move: apparently the system admin detached the database and
reattached an old version...
I can't win.
But thanks to everyone who helped out. I still have no idea what =happened
to the constraints the first time, but it's working now so that's all I =can
ask for.
Dave
"Dave" <dave@.glimmernet.com> wrote in message
news:eskCToDYDHA.2484@.TK2MSFTNGP09.phx.gbl...
> (Cross posted to the active server pages listserv at 15Seconds.com)
> A few weeks ago I posted a message about keys and relationships that
> mysteriously disappeared on our production SQL Server 2000 database. =I
> managed to restore all of the missing attributes with success. But it
> happened again this morning
> How can all of the keys and relationships in my database be wiped out =in
one
> deft move? Is there anything in the Master database or elsewhere that
could
> cause everything to disappear at once?
> The system administrator is not a DBA, so human-error is definitely a
> possibility. They are going to blame the scripts that are used to =update
> the stored procedures, but the same scripts are tested on our test
> deployment server and work flawlessly. The scripts contained no =changes
to
> database tables - they strictly updated stored procedures.
> Thanks for your help.
> Dave
>
>
>
--=_NextPart_000_038D_01C36020.23BE9B60
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Looks like she owes you lunch. =No ... wait ... she owes us lunch. Make mine medium =rare ... with a baked potato. ;-)
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Dave" wrote in message news:uSYgT8DYDHA.1492=@.TK2MSFTNGP12.phx.gbl...Well, this problem has been resolved.The one deft move: apparently the =system admin detached the database andreattached an old =version...I can't win.But thanks to everyone who helped out. I still have no =idea what happenedto the constraints the first time, but it's working now =so that's all I canask for.Dave"Dave" wrote in =messagenews:eskCToDYDHA.2484=@.TK2MSFTNGP09.phx.gbl...> (Cross posted to the active server pages listserv at 15Seconds.com)>> A few weeks ago I posted a message about =keys and relationships that> mysteriously disappeared on our production =SQL Server 2000 database. I> managed to restore all of the missing =attributes with success. But it> happened again this morning>> =How can all of the keys and relationships in my database be wiped out =inone> deft move? Is there anything in the Master database or elsewhere thatcould> cause everything to disappear at =once?>> The system administrator is not a DBA, so human-error is definitely =a> possibility. They are going to blame the scripts that are used to update> the stored procedures, but the same scripts are tested on =our test> deployment server and work flawlessly. The scripts =contained no changesto> database tables - they strictly updated stored procedures.>> Thanks for your help.>> Dave>>>>>

--=_NextPart_000_038D_01C36020.23BE9B60--|||There's no answer to that <grin>
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org