Not having luck when dropping a constraint…I am logged in as ‘sa’ which should have enough permissions to execute it but I still get:
Msg 4902, Level 16, State 1, Line 6
Cannot find the object "dbo.Products" because it does not exist or you do not have permissions.
And here is the query:
USE [PRSS10_DATABASE]
IF EXISTS (SELECT *
FROM sys.foreign_keys
WHERE object_id = OBJECT_ID(N'dbo.FK_Product_SMC')
AND parent_object_id = OBJECT_ID(N'dbo.Products')
)
ALTER TABLE [dbo.Products] DROP CONSTRAINT [FK_Product_SMC]
Now I am able to access the table.. the table exists and the Foreign key as well.. what could I be missing?
It’s the brackets. when you do
[dbo.products]that makes it think the whole object is named “dbo.products” What you want is[dbo].[Products]so that it recognizes “dbo” as the schema and “Products” as the table name.