I’ve tried to distill this issue down to the simplest SQL I could make that still shows the issue. I have a sproc in a Visual Studio Database Project that is throwing a warning in Visual Studio but is perfectly valid SQL in SQL Server. I’d like to make the warning go away. Anybody know a way to re-write the SQL to fix the warning?
CREATE PROCEDURE SampleSproc
@ResourcesXML xml
AS
BEGIN
SELECT S.PlanID FROM
(SELECT foo.x.value('@PlanID','int') AS PlanID
FROM @ResourcesXML.nodes('A') AS foo(x)) AS S
END
The warning is:
SQL04151: Procedure: [dbo].[SampleSproc] contains an unresolved reference to an object.
Either the object does not exist or the reference is ambiguous because it could refer to any of the following objects:
[@ResourcesXML].[x]::[value] or [foo].[x].[value]
It’s complaining about the foo.x.value part. Just doing x.value throws the same warning. I’m not sure what I can do to “trick” VS into thinking it’s unambiguous.
I believe the SQL04151: Unable to resolve when using the XML Nodes bug report is probably applicable and contains a workaround.