Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    47

    Unanswered: 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 ?

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    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.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •