[SQL]Create your first local db and table with visual studio

  • 250
  • 0

[SQL]Create your first local db and table with visual studio

Add a new .mdf file in your project:

double click .mdf file and new a sql query:

use following sql to create a table and insert 2 rows:

--create your first table
CREATE TABLE [dbo].[Actor]
(
	[Id] INT NOT NULL identity(1,1) PRIMARY KEY, 
    [FirstName] NVARCHAR(20) NULL, 
    [LastName] NVARCHAR(20) NULL, 
    [Title] NVARCHAR(20) NULL

)

--insert 2 rows
insert into Actor(FirstName, LastName, Title)
VALUES
(N'Chris',N'Hemsworth',N'Thor')

insert into Actor(FirstName, LastName, Title)
VALUES
(N'Tom',N'Hiddleston',N'Loki')

done, create your first local db success!

Reference:
experience from myself
Google Thor+Actor