Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
GavinD1977
Yak Posting Veteran
83 Posts |
Posted - 2006-08-11 : 04:31:28
|
| Hi allIs there anyway you can deactivate/enable all constraints on a particular table so it can be done in a script?Thanks. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-08-11 : 04:37:57
|
You can't disable a constraints. You can only DROP it.Why do you want to Disable / Enable constraints ? KH |
 |
|
|
GavinD1977
Yak Posting Veteran
83 Posts |
Posted - 2006-08-11 : 04:45:02
|
| Hi. I have a table on which there is a constraint which states start dates must not be null. I want to copy in two employees from another table where they have no startdates.I had been told the following code would do the trick (it doesnt seem to be working).EXEC SP_MSFOREACHTABLE 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'--disableEXEC SP_MSFOREACHTABLE 'ALTER TABLE ? CHECK CONSTRAINT ALL'--enable |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2006-08-11 : 08:31:17
|
| Why not update the Excel sheet with some dummy date values? It's a lot easier. It's always a bad idea to circumvent database rules and constraints just to import incomplete or invalid data. |
 |
|
|
GavinD1977
Yak Posting Veteran
83 Posts |
Posted - 2006-08-11 : 10:53:16
|
| I cant update the excel sheet. Client data is sent to us on that and we're not allowed to alter it any way (contractually).Cheers. |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2006-08-11 : 11:05:36
|
| a) Load the data into a 'parallel table' which has no/less constraints....fixup the missing fields, and then insert this 'impoved data' sideways into your real table.b) Ask your client to send on the missing data.c) Change your lawyer...to educate them on the downside of accepting such restrictive covenents!!! |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-11 : 11:44:02
|
quote: Originally posted by AndrewMurphy Change your lawyer...to educate them on the downside of accepting such restrictive covenents!!!
V should have a SQLTeam- Business Admin Forum - Soon Srinika |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-08-11 : 18:03:48
|
quote: Originally posted by AndrewMurphy a) Load the data into a 'parallel table' which has no/less constraints....fixup the missing fields, and then insert this 'impoved data' sideways into your real table.b) Ask your client to send on the missing data.c) Change your lawyer...to educate them on the downside of accepting such restrictive covenents!!!
d) Just insert some random date into the table. Random Datetime Functionhttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=69499CODO ERGO SUM |
 |
|
|
|
|
|