Friday, July 24, 2009

How to Add a Foriegn Key Relationship to a table

ALTER TABLE [dbo].[FactLocateOrdersSKUAggYear] WITH CHECK ADD CONSTRAINT [FK_FactLocateOrdersSKUAggYear_DimBrand] FOREIGN KEY([dw_brand_id])
REFERENCES [dbo].[DimBrand] ([brand_id])
GO

ALTER TABLE [dbo].[FactLocateOrdersSKUAggYear] CHECK CONSTRAINT [FK_FactLocateOrdersSKUAggYear_DimBrand]
GO

Note: Datatypes must be the same for columns in the relationship or a data type error will occur.

No comments:

Post a Comment