I have a very basic question about SQL server and Visual Studio 2010. I'm currently reading the book "C# 3.0 Unleashed with the .NET framework 3.5". I'm at the chapter where LINQ to SQL is explained. The writer asks to create a new database and use his script (given in the book) to create the tables and fill these with some data.
However, as I've never worked with SQL server before, this part is a bit confusing for me. The writer doesn't explain how to create the database. First I thought I could just right-click on Data Connections -> Create New SQL Server Database. However, when I tried that, I only got an error explaining no connection could be made.
When that didn't work, I added a new Service-based Database via Add -> New Item. This works (although I do not understand the difference between this and the previous thing I've tried. If someone could explain this for me, It'd be very appreciated), but now I'm supposed to use the script to create the tables and enter some data. I can right-click on the database and select New Query, but that window doesn't seem to accept such scripts.
First part of the script:
/****** Object: Table [dbo].[HospitalStaff]Script Date: 12/29/2007 21:42:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (
SELECT * FROM sys.objects
WHERE object_id = OBJECT_ID(N’[HospitalStaff]’)
AND type in (N’U’))
BEGIN
CREATE TABLE [HospitalStaff](
[HospitalStaffID] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50)
COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Position] [varchar](50)
COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
CONSTRAINT [PK_HospitalStaff] PRIMARY KEY CLUSTERED
(
[HospitalStaffID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON)
)
END
I know it's a very basic question, but where can I execute this script? I've visited several websites with SQL server tutorials, but it's all pretty confusing.
