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
364 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 125 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with SQL joins 9 43
Two tables - Sum of values - What is the difference 31 48
Following an example - removing duplicate strings 4 48
Restrict result set 1 33
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now