Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:01:13+00:00 2026-05-31T04:01:13+00:00

I am trying to create a database from a SQL query I’ve been sent.

  • 0

I am trying to create a database from a SQL query I’ve been sent. Should point out SQL is not my strong point.

The following is declared at the start of the query:

:setvar DatabaseName "Database"
:setvar DefaultDataPath ""
:setvar DefaultLogPath ""

I have run the query in command mode and am getting the following error:

Creating Database…
Msg 5105, Level 16, State 2, Line 1
A file activation error occurred. The physical file name ‘DB.mdf’ may be incorrect. Diagnose and correct additional errors, and retry the operation.

Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
An error was encountered during execution of batch. Exiting.

Any ideas?

Thanks

Can’t post full query as is very long and contains sensitive info but is cut down version up to the point that seems to cause the error.

SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;
SET NUMERIC_ROUNDABORT OFF;
GO

:setvar DatabaseName "Database"
:setvar DefaultDataPath ""
:setvar DefaultLogPath ""
GO

:on error exit
GO

USE [master]
GO

IF (DB_ID(N'$(DatabaseName)') IS NOT NULL
AND DATABASEPROPERTYEX(N'$(DatabaseName)','Status') <> N'ONLINE')
BEGIN
RAISERROR(N'The state of the target database, %s, is not set to ONLINE. To deploy to this database, its state must be set to ONLINE.', 16, 127,N'$(DatabaseName)') WITH NOWAIT
RETURN
END
GO

IF (DB_ID(N'$(DatabaseName)') IS NOT NULL) 
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
DROP DATABASE [$(DatabaseName)];
END
GO

PRINT N'Creating $(DatabaseName)...'
GO

CREATE DATABASE [$(DatabaseName)]
ON 
PRIMARY(NAME = [DB], FILENAME = '$(DefaultDataPath)DB.mdf', SIZE = 3072 KB, FILEGROWTH = 1024 KB)
LOG ON (NAME = [DB_log], FILENAME = '$(DefaultLogPath)DB_log.ldf', SIZE = 1024 KB, MAXSIZE = 2097152 MB, FILEGROWTH = 10 %) COLLATE SQL_Latin1_General_CP1_CI_AS
GO

EXECUTE sp_dbcmptlevel [$(DatabaseName)], 100;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:01:15+00:00Added an answer on May 31, 2026 at 4:01 am

    put some physical path in the following line:

    :setvar DefaultDataPath ""
    

    like;

    :setvar DefaultDataPath "D:\Database"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I'm trying to create a SQL 2005 query to retrieve and combine records from
I'm trying to create a simple button that deletes a row from the database.
I'm trying to create a simple database table using the PHP MySQL query Create
I am trying to create entities out of a SQLite database. SQLite doesnt have
I am trying to create a LINQ to SQL query and am really stumped.
I'm trying to create a query in an access database for a C# dataset
im trying to create a sql query, that will detect (possible) duplicate customers in
I'm trying to create the following query in CI using ActiveRecord SELECT *, (
I'm new to SQLite3 with iOS I'm trying to create an SQL Query that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.