Solved

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

Posted on 2011-03-07
2
448 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 500 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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