Solved

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

Posted on 2011-03-07
2
436 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
2 Comments
 
LVL 142

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now