I'm trying to learn SQL Server and I'm practicing INSERT INTO
.
When I try to enter this query, it throws an error saying that [Intern_DB2].[dbo].[MY_Parcels]
is an invalid object.
I had no problems creating this table, why is it saying its invalid all of a sudden?
Insert INTO [INTERN_DB2].[dbo].[My_Parcels] (ID)
Values (000065, N'test')
You have two problems with your query .
1st
Insert INTO [INTERN_DB2].[dbo].[My_Parcels] (ID) --<-- Number of columns 1
Values (000065, N'test') --<-- Passed values for two columns
The number of columns mentioned in your INSERT INTO statement must match the number of values passed in VALUES
cluase.
2nd
You are getting Error message something along the lines invalid object
which means you have not used the correct Table name or you have created that table in some other database and looking for it in some other database
to check this try Executing the following statement and see if table exists
USE INTERN_DB2
GO
SELECT * FROM [dbo].[My_Parcels]
GO
Once you have made sure the tables exists , just correct the number of values passed in VALUES claues of your insert statement and it should work.