I'm trying to create a local copy of a popular CRM database called
Salesforce.com. Many of the tables in the DB have FOREIGN KEY
references that I want to preserve, but I've run into a chicken and egg
problem. Table "A" has a reference to table "B," and table "B" has a
reference to table "A." So I can't CREATE one until the other exists.
Is there a way to disable these checks until I've created all the
schema?
Here's what I see (error first, then SQL that caused it):
Server: Msg 1767, Level 16, State 1, Line 1
Foreign key 'FK__UserRole__ LastMo__48CFD27 E' references invalid table
'User'.
Server: Msg 1750, Level 16, State 1, Line 1
Could not create constraint. See previous errors.
CREATE TABLE salesforce3.dbo ."UserRole" ("Id" varchar(18) PRIMARY KEY ,
"Name" varchar(40), "ParentRole Id" varchar(18) REFERENCES
"UserRole"( Id), "RollupDescript ion" varchar(80),
"OpportunityAcc essForAccountOw ner" varchar(40),
"CaseAccessForA ccountOwner" varchar(40), "LastModifiedDa te" datetime,
"LastModifiedBy Id" varchar(18) REFERENCES "User"(Id), "SystemModstamp "
datetime);
CREATE TABLE salesforce3.dbo ."User" ("Id" varchar(18) PRIMARY KEY ,
"Username" varchar(80), "LastName" varchar(80), "FirstName"
varchar(40), "CompanyNam e" varchar(80), "Division" varchar(80),
"Department " varchar(80), "Title" varchar(80), "Street" text, "City"
varchar(40), "State" varchar(20), "PostalCode " varchar(20), "Country"
varchar(40), "Email" varchar(80), "Phone" varchar(40), "Fax"
varchar(40), "MobilePhon e" varchar(40), "Alias" varchar(8), "IsActive"
bit, "TimeZoneSidKey " varchar(40), "UserRoleId " varchar(18) REFERENCES
"UserRole"( Id), "LocaleSidK ey" varchar(40), "ReceivesInfoEm ails" bit,
"ReceivesAdminI nfoEmails" bit, "EmailEncodingK ey" varchar(40),
"ProfileId" varchar(18) REFERENCES "Profile"(I d), "LanguageLocale Key"
varchar(40), "EmployeeNumber " varchar(20), "WirelessEm ail" varchar(80),
"LastLoginD ate" datetime, "CreatedDat e" datetime, "CreatedByI d"
varchar(18) REFERENCES "User"(Id), "LastModifiedDa te" datetime,
"LastModifiedBy Id" varchar(18) REFERENCES "User"(Id), "SystemModstamp "
datetime, "UserPermission sMarketingUser" bit,
"UserPermission sOfflineUser" bit, "UserPermission sWirelessUser" bit,
"UserPermission sSuperCssUser" bit, "UserPermission sAvantgoUser" bit); 2 8398
<ad**********@m arketsquaresolu tions.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. . I'm trying to create a local copy of a popular CRM database called Salesforce.com. Many of the tables in the DB have FOREIGN KEY references that I want to preserve, but I've run into a chicken and egg problem. Table "A" has a reference to table "B," and table "B" has a reference to table "A." So I can't CREATE one until the other exists. Is there a way to disable these checks until I've created all the schema?
Here's what I see (error first, then SQL that caused it):
Server: Msg 1767, Level 16, State 1, Line 1 Foreign key 'FK__UserRole__ LastMo__48CFD27 E' references invalid table 'User'. Server: Msg 1750, Level 16, State 1, Line 1 Could not create constraint. See previous errors.
CREATE TABLE salesforce3.dbo ."UserRole" ("Id" varchar(18) PRIMARY KEY , "Name" varchar(40), "ParentRole Id" varchar(18) REFERENCES "UserRole"( Id), "RollupDescript ion" varchar(80), "OpportunityAcc essForAccountOw ner" varchar(40), "CaseAccessForA ccountOwner" varchar(40), "LastModifiedDa te" datetime, "LastModifiedBy Id" varchar(18) REFERENCES "User"(Id), "SystemModstamp " datetime);
CREATE TABLE salesforce3.dbo ."User" ("Id" varchar(18) PRIMARY KEY , "Username" varchar(80), "LastName" varchar(80), "FirstName" varchar(40), "CompanyNam e" varchar(80), "Division" varchar(80), "Department " varchar(80), "Title" varchar(80), "Street" text, "City" varchar(40), "State" varchar(20), "PostalCode " varchar(20), "Country" varchar(40), "Email" varchar(80), "Phone" varchar(40), "Fax" varchar(40), "MobilePhon e" varchar(40), "Alias" varchar(8), "IsActive" bit, "TimeZoneSidKey " varchar(40), "UserRoleId " varchar(18) REFERENCES "UserRole"( Id), "LocaleSidK ey" varchar(40), "ReceivesInfoEm ails" bit, "ReceivesAdminI nfoEmails" bit, "EmailEncodingK ey" varchar(40), "ProfileId" varchar(18) REFERENCES "Profile"(I d), "LanguageLocale Key" varchar(40), "EmployeeNumber " varchar(20), "WirelessEm ail" varchar(80), "LastLoginD ate" datetime, "CreatedDat e" datetime, "CreatedByI d" varchar(18) REFERENCES "User"(Id), "LastModifiedDa te" datetime, "LastModifiedBy Id" varchar(18) REFERENCES "User"(Id), "SystemModstamp " datetime, "UserPermission sMarketingUser" bit, "UserPermission sOfflineUser" bit, "UserPermission sWirelessUser" bit, "UserPermission sSuperCssUser" bit, "UserPermission sAvantgoUser" bit);
If you have access to a source database, then Enterprise Manager can script
tables and constraints separately, so you could generate one script to
create the tables, then a second to add the constraints with ALTER TABLE.
Alternatively, if all you have to go on is your script, you can use CREATE
SCHEMA (see Books Online):
create schema authorization dbo
create table UserRole (...)
create table [User] (...)
By the way, "User" is a reserved word in MSSQL, so it isn't a good choice
for a table name, but I assume that if it's a third-party product, you can't
do much about that anyway.
Simon
(ad**********@m arketsquaresolu tions.com) writes: I'm trying to create a local copy of a popular CRM database called Salesforce.com. Many of the tables in the DB have FOREIGN KEY references that I want to preserve, but I've run into a chicken and egg problem. Table "A" has a reference to table "B," and table "B" has a reference to table "A." So I can't CREATE one until the other exists. Is there a way to disable these checks until I've created all the schema?
Just do:
CREATE TABLE this_one
CREATE TABLE that_one
...
ALTER TABLE this_one ADD CONSTRAINT fk_this_that FOREIGN KEY ...
ALTER TABLE that_one ADD CONSTRAINT fk_that_this FOREIGN KEY ...
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robert Rae |
last post by:
OS XP Pro SP2
MYSQL Ver: 5.0.0-alpha nt
Whenever I view a table or run a query in the Control Center (0.9.4-beta) I
get the following error:
ERROR 1146: Table 'shipnet.1' doesn't exist
table shipnet.1 indeed does not exist but I can't understand why it's
looking for it. Any ideas?
|
by: CLarkou |
last post by:
On a client's machine with Office 97, my access program gives an error
"The Expression you entered refers to an object that is closed or
doesn't exist" when I am assigning a value in the checkbox.
chk_multiuser.Value = 0
What could be the cause of this error ?
|
by: Regnab |
last post by:
I'm automating the import of all text files into Access from a source
folder. I was getting the "Field 'F1' doesn't exist in destination
table" error, so I checked it out on the net and it said to create a
import specification. So I did this (InductionImport), and included it
in my code as below:
DoCmd.TransferText acImportDelim, InductionImport,
"ImportedInductionLots", CurrentPath & strfile, 0
I created the import specs as per...
|
by: Mike |
last post by:
Hi
I've written my first asp.net page below. It queries an Access database with
one table consisting of two columns - a username and a server name. The
users enter their login name and the page queries the database and then
directs them to the correct server. This works fine as long as their name
actually exists in the database. If it doesn't the the page fails at the
server = dataSet.Tables(0).Rows(0).Item(0).ToString()
|
by: Phil Galey |
last post by:
I created an About box and am able to get all the assembly information from the program to show up in the About box except the Version.
I created the About box as a separate Windows application, changed the Output to Class Library, and compile it as a DLL. I then reference it from my program. In the About Box form's Public Sub New routine, I placed the following code, where I'm getting all the assembly attributes from the calling...
| |
by: H5N1 |
last post by:
hi there
the topic says it all.
I have a outer join select statement in tableadapter that populates
GridView, I want to make it updatetable, so I need to provide an update
command for table adapter.
the problem is that not all rows in gridview exist in database (since
it's an outer join) so I want to UPDATE statement to insert the row if
it doesn't exist.
|
by: LanaR |
last post by:
Hi,
I need to create sql script that creates a table if it doesn't exist.
I tried to use
if not exists
(select * from sysibm.systables where name ='mytable'
then
create table mytable ...
...
|
by: abdoelmasry |
last post by:
Hi Men
i have real problem using mysql database
i make database for my site with mysql
it have very important data
but i think the database tables corrupted
|
by: kilo |
last post by:
Hey.. I need someone hwo can help me making my sql table..
I have no php skills. I have payed for a php program that shoud make dictation for people that have some problems reading danish.. with sound and text..
When I'm making the dictation with PHP I'm getting an error like this.: Query failed (SELECT word FROM repository): Table 'test_dig_dk.repository' doesn't exist
the first one of the php, that I soud use for makeing the text is..
...
|
by: moltendorf |
last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables that are supposed to be there, but running a SELECT * FROM `configuration`; (for example) returns "test.configuration does not exist).
I've tried the following repair statement since I'm not too familiar with backing up and restoring data.
...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |