fread
fread

Reputation: 63

Getting an error in SQL Server Management Studio

I am just getting started with using Microsoft SQL Server Management Studio. I am using SQL Server 2014 with this. I am following a tutorial on YouTube so that I can learn how to create a database with this software.

However, I get an error:

Msg 208, Level 16, State 1, Line 4
Invalid object name 'temp'.

Here is my list of commands so far. Everything executed until the 3rd line:

create database youtube

create table temp(id int, name varchar(20))

insert into temp 
values (1, 'hello'), (2, 'Abc'), (3, 'John'), (4, 'Harry'), 
       (5, 'Shaun'), (6, 'Mike')

If it helps with figuring out the problem, I did leave this thing alone for about 30 minutes or so to go have lunch, and when I came back I was disconnected from the server. I reconnected to the server, and that's when the problem started coming up.

I also have the link to the YouTube video right here so you can see where I got this from: https://www.youtube.com/watch?v=-Vv7qYhEixo

Upvotes: 0

Views: 62

Answers (1)

Zack
Zack

Reputation: 2341

As noted by @scsimon, you can change your active database in the SSMS window.

You can also use the USE command to change your active database: use youtube.

Finally, it's a good idea to commit each step of your DDL (database creation, table creation, etc.). For example:

create database youtube
go

use youtube
go

create table temp(id int, name varchar(20))
go

insert into temp 
values (1, 'hello'), (2, 'Abc'), (3, 'John'), (4, 'Harry'), 
       (5, 'Shaun'), (6, 'Mike')

Upvotes: 1

Related Questions