Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is it possible to create a Foreign Key from BIGINT to NUMERIC(19,0) in SQL Server 2005?

Posted on 2008-06-19
4
Medium Priority
?
376 Views
Last Modified: 2012-06-27
I have two tables.

TEST1
TEST_KEY numeric(19,0) IDENTITY,
TEST_DESC varchar(20)

TEST2
TEST_KEY BIGINT NOT NULL
TEST_NAME varchar(50)

I am trying to use SQL Analysis Server to create a relationship between those two tables but I get an error that the data types are different. Is there a setting to let SQL Server know that they are similar and to allow the relationship to be built?
0
Comment
Question by:gumby34
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
vasureddym earned 500 total points
ID: 21823055
There are 2 rules to create a foreign key:
1) There should be a primary key on the master table. In your example, it is not clear about the primary key.
2) The datatypes of the Primary key in the master table and the referring column in the child table must be same. in your example, the two columns are of different datatype  numeric(19,0) and Bigint.

If these two rules are not met SQL Server doesn't allow to create FK.
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 21823053
I am pretty sure that AA requires that the two fields be of the exact same data type...
0
 

Author Comment

by:gumby34
ID: 21823180
vasureddym: Thanks I forgot to include the PK info. Both tables have the PK defined as the TEST_KEY.

chapmandew: Thanks for the reply

I guess that we will have to change the datatypes on the second table to numeric(19,0) in order to get this to work.
0
 

Author Closing Comment

by:gumby34
ID: 31468822
Thanks for your help
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question