I am trying to write this code in a Storage Procedure in Visual Studio 2019 Preview.
(To mention is that this code works anyway. But I wonder about those unresolved references if this will result in any problem?)
But as seen in the image below, I get this error for the line: INFORMATION_SCHEMA.TABLES
SQL71502: Procedure: [dbo].[createNewTable] has an unresolved reference to object [INFORMATION_SCHEMA].[TABLES].
I don't know exactly what error this is. I googled and found this but are not sure if this is the problem?. However, I can't find any "References" in the Solution Explorer(See image below):
Add a database reference to master:
Under the project, right-click References.
Select Add database reference....
Select System database.
Ensure master is selected.
Press OK.
CREATE PROCEDURE createNewTable
AS
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'testTable5')
BEGIN
CREATE TABLE testTable5
(
[DateTime] SMALLDATETIME NOT NULL,
[FeatureNbr] SMALLINT NOT NULL,
[Value] FLOAT (53) NULL,
[Bool] BIT NULL,
CONSTRAINT UC_testTable5 UNIQUE (DateTime),
CONSTRAINT PK_testTable5 PRIMARY KEY (FeatureNbr, DateTime)
);
END