?
Solved

SQL Script Error - Could not locate entry in sysdatabases for database 'PIMTool'

Posted on 2011-03-07
2
Medium Priority
?
466 Views
Last Modified: 2012-05-11


I am getting the following error for the SQL Script below and I cannot figure out why.  Any suggestions?  Also, since I have two SQL server instances on my computer a LOCAL and a SQLExpress do I need to specify anything in the SQL script file when I executing this through a MSI installer.  I receive the error message when I try running this script through Query Analyzer againast the SQLExpress instance.  

Server: Msg 911, Level 16, State 1, Line 1
Could not locate entry in sysdatabases for database 'PIMTool'. No entry found with that name. Make sure that the name is entered correctly.

use Master;
if exists (SELECT name FROM Master.dbo.sysdatabases WHERE name = N'PIMTool')
drop DATABASE [PIMTool];
GO

IF not EXISTS (SELECT name FROM Master.dbo.sysdatabases WHERE name = N'PIMTool')
CREATE DATABASE [PIMTool];
GO
use PIMTool;
0
Comment
Question by:Hojoformo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 35058337
please try to change:
drop DATABASE [PIMTool];

into:
exec('drop DATABASE [PIMTool]')
0
 
LVL 14

Expert Comment

by:Daniel_PL
ID: 35066813
You can also put BEGIN, END there:

if exists (SELECT name FROM Master.dbo.sysdatabases WHERE name = N'PIMTool')
BEGIN
drop DATABASE [PIMTool];
END
GO
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills PIVOT is a great facility and solves many an EAV (Entity - Attribute - Value) type transformation where we need the information held as data within a column to become columns in their own right. Now, in some cases that is relatively…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question