Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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