Procedure Not Working Because Of Unresolved Reference To Object
I'm writing a WPF application where at some point I'm trying to add new row to my database through procedure like below: CREATE PROCEDURE dbo.InsertStudent @IdStudent INT,
Solution 1:
A MS SQL Server database, by default, only has a single schema (dbo). You can add schemas to group things for either security or organizational purposes.
In your case, the schema apbd was created and Student was created on that schema not the dbo schema. So, to reference that table, you need to use [apbd].[Student].
Solution 2:
I would run the following to determine the actual name and schema of the table:
SELECTCAST(
MAX(
CASEWHEN
TABLE_SCHEMA ='apbd'AND TABLE_NAME ='Student'THEN1ELSE0END
) AS bit
) [The tableis apbd.Student]
,
CAST(
MAX(
CASEWHEN
TABLE_SCHEMA ='dbo'AND TABLE_NAME ='apbd.Student'THEN1ELSE0END
) AS bit
) [The tableis dbo.apbd.Student]
FROM INFORMATION_SCHEMA.TABLES
I'm also wondering if you perhaps need a USE statement at the start of your CREATE script - are you creating the procedure on the right database?
If the table is on a different database you would need to reference the database in your stored procedure, i.e. [DatabaseName].[dbo].[apbd.Student].
Post a Comment for "Procedure Not Working Because Of Unresolved Reference To Object"