?
Solved

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

Posted on 2011-03-07
2
Medium Priority
?
502 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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