I've following script. I dont understand how to create new database in sql server 2005. I run following scirpt, also it create tables under model rather than seperate databse. it look massy.

how do i create seperate databse. I'm copy some script for your adive and strategy.

-----------------------------------------------------------
-- SQL Server 2000 Bible 
-- Hungry Minds 
-- Paul Nielsen

-- OBX Kites sample database - CREATE Database, Tables, and Procs

-- this script will drop an existing OBXKites database 
-- and create a fresh new installation

-- related scripts:
-- OBXKites_Populate

-- T-SQL KEYWORDS go
-- DatabaseNames   

-----------------------------------------------------------
-----------------------------------------------------------
-- Drop and Create Database


USE master
GO
IF EXISTS (SELECT * FROM SysDatabases WHERE NAME='OBXKites')
  DROP DATABASE OBXKites
go

-- This creates 1 database that uses 2 filegroups
CREATE DATABASE OBXKites
  ON PRIMARY
    (NAME = 'OBXKites', FILENAME = 'D:\SQLData\OBXKites.mdf'),
  FILEGROUP Static
    (NAME = 'OBXKitesStatic', FILENAME = 'c:\SQLData\OBXKitesStatic.ndf')
  LOG ON (NAME = 'OBXKitesLog',  FILENAME = 'c:\SQLData\OBXKites.ldf')
go

-- set to Full Log

go

SET QUOTED_IDENTIFIER ON
go
USE OBXKites
go

-----------------------------------------------------------
-----------------------------------------------------------
-- Create Tables, in order from primary to secondary

CREATE TABLE dbo.OrderPriority (
  OrderPriorityID UNIQUEIDENTIFIER NOT NULL ROWGUIDCOL DEFAULT (NEWID()) PRIMARY KEY NONCLUSTERED,
  OrderPriorityName NVARCHAR (15) NOT NULL,
  OrderPriorityCode NVARCHAR (15) NOT NULL,
  Priority INT NOT NULL
  )
  ON [Static]
go
CREATE DATABASE OBXKites
ON PRIMARY
     (NAME = 'OBXKites', FILENAME = 'D:\SQLData\OBXKites.mdf'),  
   FILEGROUP Static
     (NAME = 'OBXKitesStatic', FILENAME = 'c:\SQLData\OBXKitesStatic.ndf')
LOG ON 
   (NAME = 'OBXKitesLog',  FILENAME = 'c:\SQLData\OBXKites.ldf')
go

This code inside your script should produce a new database. If no error occurrs along the way.

What are the errors in output? The script itself does already do that which you asked for.

I'd suspect that you simply improperly specified filenames - a number of them take presctiption drive C:, plus some on drive D:.

Your script under consideration can create the tables within the OBXKites database (begin to see the USE OBXKites statement inside your script)

Does the OBXKites database already appear in your server instance? If that's the case, that's most likely why it seems that it's creating the tables in the present database, because the script is effectively getting rid of and re-creating the OBXKites database. Should you prefer a different reputation for the database, find all cases of "OBXKites" inside your script above following the line that reads "This produces 1 database that utilizes 2 filegroups" and relabel it towards the new database title you would like.

The only real other option might be the script has execution errors creating the database, in case your user account lacks the correct permissions to do this. However, the script is constantly on the execute, creating the tables in the present database you're drenched directly into, and that's why you're seeing the tables there.

Are you able to simplify it lower? or is it necessary to do all that checking?

If it may be simplified I beileve some code for example:

CREATE DATABASE OBXKites

USE OBXKites

CREATE TABLE OrderPriority(syntax)

If simple code such as this does not work, you might have much deeper difficulties with privileges or files or something like that as recommended by queen3 right before me.

Afterthought: Inside my school i was getting issues such as this too In my opinion... following a couple of classes we finally arived by the end that people did not have privileges to include files towards the program files directory around the lab computer systems and SQL wasn't confirming the mistake to us.