If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > whats wrong in this code ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-12-12, 09:57
navedjobs navedjobs is offline
Registered User
 
Join Date: Sep 2011
Posts: 35
whats wrong in this code ?

whats wrong in this code
any time i run from ms sql it throws an error
Code:
Could not locate entry in sysdatabases for database 'Trail1'. No entry found with that name. Make sure that the name is entered correctly.
Code:
create database Trail1;

use Trail1;

create table BasicCompanyInfo(
varchar(50) null Company_Name,
varchar(50) null Address,
varchar(50) null Branch,
varchar(50) null Contact_No,
varchar(50) null Website,
int null Counter  
);
i m writing a script to create a database structure when executed
but this starting code throws some exception
why so ?
Reply With Quote
  #2 (permalink)  
Old 01-12-12, 11:02
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Can you do that?

Is this SQL server?

Code:
IF  EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'<db_name>')
  BEGIN

	ALTER DATABASE [<db_name>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
	DROP DATABASE [<db_name>]

  END
GO


CREATE DATABASE [<db_name>] ON  PRIMARY 
( NAME = N'<db_name>',		FILENAME = N'<fp>\<db_name>.MDF' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'<db_name>_LOG',	FILENAME = N'<fp>\<db_name>.LDF' , SIZE = 3840KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [<db_name>] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [<db_name>].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [<db_name>] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [<db_name>] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [<db_name>] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [<db_name>] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [<db_name>] SET ARITHABORT OFF 
GO

ALTER DATABASE [<db_name>] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [<db_name>] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [<db_name>] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [<db_name>] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [<db_name>] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [<db_name>] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [<db_name>] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [<db_name>] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [<db_name>] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [<db_name>] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [<db_name>] SET  DISABLE_BROKER 
GO

ALTER DATABASE [<db_name>] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [<db_name>] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [<db_name>] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [<db_name>] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [<db_name>] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [<db_name>] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [<db_name>] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [<db_name>] SET  READ_WRITE 
GO

ALTER DATABASE [<db_name>] SET RECOVERY FULL 
GO

ALTER DATABASE [<db_name>] SET  MULTI_USER 
GO

ALTER DATABASE [<db_name>] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [<db_name>] SET DB_CHAINING OFF 

GO
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #3 (permalink)  
Old 01-12-12, 13:17
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
You need to have a GO between the create database statement and the use database statement.

EDIT: You also appear to have a very strange create table syntax. Column names usually come first.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On