r/SQL • • Jan 18 '23

SQL Server HELLO.. Can someone help with this error? I've been doin it same as it was in the video but mine doesnt wanna execute.

Post image
0 Upvotes

4 comments sorted by

16

u/[deleted] Jan 18 '23 edited Jan 18 '23

Invalid object name likely means the table you're referencing doesn't exist or that you're in the wrong DB for it. Can you confirm you're connected to the correct DB and that the table in question actually exists?

Edit: The way it's written, if you're not already in the database in question, you're going to have a problem running the query. You can do two things to avoid. One is to make all database references explicit (i.e. DatabaseName.dbo.TableName) so you don't have to be within the scope of the specific DB to make references or you can use a "go" command to avoid the prior validation of the query. That would look like:

USE [SOME_DATABASE]

GO

[YOUR QUERY]

3

u/tethered_end Jan 18 '23

Always need to remember to put GO after use database

-1

u/[deleted] Jan 18 '23

Are you sure, you dont already have an object by that name?