Importing a script into SQL Server Express

I am having trouble importing a database script into SQL Server Express. The script is from the Web Applications book from the Microsoft MCSD exams. My installation of SQL Server Express appears to be fine as I can login and create/delete databases through it. When I attempt to import the database script I get a variety of errors as follows:
Msg 911, Level 16, State 1, Server ORTHANC\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Contacts'. No entry found with that name. Make sure that the name is entered correctly.
Msg 15401, Level 16, State 1, Server ORTHANC\SQLEXPRESS, Line 1
Windows NT user or group 'ORTHANC\SQLEXPRESS\ASPNET' not found. Check the name again.
Msg 15410, Level 11, State 1, Server ORTHANC\SQLEXPRESS, Procedure sp_addrolemember, Line 80
User or role 'aspnet' does not exist in this database.
Msg 15410, Level 11, State 1, Server ORTHANC\SQLEXPRESS, Procedure sp_addrolemember, Line 80
User or role 'aspnet' does not exist in this database.
I have added access permissions for the ASPNET user account on the SQL Server Express folder but that doesn't appear to have helped. I'm not sure if the error about contacts.mdf means that I should have a contacts.mdf created as a result of the script or whether it should be there to begin with.
 
I found this thread http://forums.asp.net/thread/433540.aspx but it didn't solve my problem.

Apologies for the length of the post. Any help at all is greatly appreciated! 
 
0
Malice
4/1/2006 12:57:20 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
759 Views

Similar Articles

[PageSpeed] 34

I think we are going to neeed to see the script you are trying to run.  

Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
4/1/2006 1:04:17 PM

The script is the the one from the MCSD Web apps book. After installation off the CD it's available from C:\Microsoft Press\MCSDWebApps2\Databases. Leaving out the test data added at the bottom of the script it looks like this:

USE master
GO
if exists (select * from sysdatabases where name='Contacts')
drop database Contacts
go

DECLARE @device_directory NVARCHAR(520)
SELECT @device_directory = SUBSTRING(phyname, 1, CHARINDEX(N'master.mdf', LOWER(phyname)) - 1)
FROM master.dbo.sysdevices
WHERE (name = N'master')

EXECUTE (N
'CREATE DATABASE Contacts
  ON PRIMARY (NAME = N''Contacts'', FILENAME = N'''
+ @device_directory + N
'contacts.mdf'')
  LOG ON (NAME = N''Contacts_log'',  FILENAME = N'''
+ @device_directory + N'contacts.ldf'')')
go

exec sp_dboption 'Contacts','trunc. log on chkpt.','true'
exec sp_dboption 'Contacts','select into/bulkcopy','true'
go

set quoted_identifier on
GO
/* Set DATEFORMAT so that the date strings are interpreted correctly regardless of
   the default DATEFORMAT on the server.
*/

SET DATEFORMAT mdy
GO
use "Contacts"

GO
/****** Object:  Table [dbo].[Calls]    Script Date: 3/7/2002 1:52:49 PM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Calls]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Calls]
GO

/****** Object:  Table [dbo].[Contact Types]    Script Date: 3/7/2002 1:52:49 PM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Contact Types]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Contact Types]
GO

/****** Object:  Table [dbo].[Contacts]    Script Date: 3/7/2002 1:52:49 PM ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Contacts]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Contacts]

GO

/****** Object:  Table [dbo].[Calls]    Script Date: 3/7/2002 1:52:51 PM ******/
CREATE TABLE [dbo].[Calls] (
[CallID] [int] NOT NULL ,
[ContactID] [int] NOT NULL ,
[CallDate] [datetime] NULL ,
[CallTime] [datetime] NULL ,
[Subject] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Notes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

GRANT  REFERENCES ,  SELECT ,  INSERT ,  DELETE ,  UPDATE  ON "Calls"  TO "public"
GO

/****** Object:  Table [dbo].[Contact Types]    Script Date: 3/7/2002 1:52:55 PM ******/
CREATE TABLE [dbo].[Contact Types] (
[ContactTypeID] [int] NOT NULL ,
[ContactType] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

GRANT  REFERENCES ,  SELECT ,  INSERT ,  DELETE ,  UPDATE  ON "Contact Types"  TO "public"
GO



/****** Object:  Table [dbo].[Contacts]    Script Date: 3/7/2002 1:52:55 PM ******/
CREATE TABLE [dbo].[Contacts] (
[ContactID] [int] NOT NULL ,
[FirstName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LastName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Dear] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Address] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[City] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[StateOrProvince] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[PostalCode] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Region] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Country] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CompanyName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Title] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WorkPhone] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[WorkExtension] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[HomePhone] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[MobilePhone] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[FaxNumber] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[EmailName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Birthdate] [smalldatetime] NULL ,
[LastMeetingDate] [smalldatetime] NULL ,
[ContactTypeID] [int] NULL ,
[ReferredBy] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Notes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[ContactsInterests] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

GRANT  REFERENCES ,  SELECT ,  INSERT ,  DELETE ,  UPDATE  ON "Contacts"  TO "public"
GO


DECLARE @srv varchar(100)
SET @srv = @@SERVERNAME + '\ASPNET'


if not exists (select * from dbo.sysusers where name = N'aspnet' and uid < 16382)
EXEC sp_grantdbaccess @srv, N'aspnet'
GO

if not exists (select * from dbo.sysusers where name = N'guest' and uid < 16382 and hasdbaccess = 1)
EXEC sp_grantdbaccess N'guest'
GO

exec sp_addrolemember N'db_datareader', N'aspnet'
GO

exec sp_addrolemember N'db_datawriter', N'aspnet'
GO


ALTER TABLE [dbo].[Calls] WITH NOCHECK ADD
CONSTRAINT [PK__Calls__59063A47] PRIMARY KEY  CLUSTERED
(
[CallID]
)  ON [PRIMARY]
GO

ALTER TABLE [dbo].[Contact Types] WITH NOCHECK ADD
CONSTRAINT [PK__Contact Types__5AEE82B9] PRIMARY KEY  CLUSTERED
(
[ContactTypeID]
)  ON [PRIMARY]
GO

ALTER TABLE [dbo].[Contacts] WITH NOCHECK ADD
CONSTRAINT [PK__Contacts__5CD6CB2B] PRIMARY KEY  CLUSTERED
(
[ContactID]
)  ON [PRIMARY]
GO

 
0
Malice
4/1/2006 6:02:08 PM
Since that script is from 2002, I am guessing that it's targeted for SQL Server 2000.  It runs fine for me in Query Analyzer for my local SQL Server 2000.  

How are you going about running it for your SQL Express database?

Terri Morton
Engagement Manager, Neudesic

How to ask a question

0
tmorton
4/1/2006 6:19:21 PM

There's a batch file in the folder that runs the following command:

osql -i InstContacts.Sql -E

That produces the same errors if I use the more up to date sqlcmd with this command line:

sqlcmd -S orthanc\sqlexpress -i c:\contacts.sql -o result.txt

The first error refers to "contacts.mdf" and suggests that the name is incorrect. Should I have a contacts.mdf file or is it created by the script when it executes correctly?

 

0
Malice
4/1/2006 7:09:39 PM
Reply:

Similar Artilces:

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf file...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf files ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi,Basically i built a webpage with Login and it's working well from my local machine.Right now, i'm using Database Publishing Wizard. the problem is how do i convert.MDF files to .SQL 2005 to get my database publish in the internet? thanks  Place your .MDF file in the App_Data directory, change the connection string accordingly and then publish your web site. ----------------------------------------------------------Please click Mark As Answer if this helped in solving your problem.  Please click "Mark As Answer" if this hepled in solving your problem. ...

How to export sql server 2005 express for import on web sql server
Hi,  I'm new to SQL Server 2005 Express and SQL.  I've been using Access for year and have not moved on to asp.net for my website.  I understand from 1and1.com that I will need to imort a backup of my SQL Server 2005 Express file to my on site database. I don't find any way to do that.  Please advise as to how I get the express version to work on my site. Thanks! Leesha Did you install the SQL Management Studio?  In the toolkit... JeffPlease: Don't forget to click "Mark as Answer" on the post that helped you. That way future rea...

SQL Server 2005 Installation problems with SQL Server Express & SQL Server 2000
Hi Guys, I have had SQL Server Express and Sql Server Management Studio Express installed on my machine for some time and recently tried to install a trial of SQL Server 2005 as well.  (Yes, I'm migrating from Visual Studio Express to Visual Studio Professional, just as in tended!) Everything went fine except that nothing seemed to be installed.  I searched in all the obvious places - both on the Start/Programs menu and on the hard-drive: nothing. A check under Add/Remove Programs showed that Sql Server 2005 Express was installed, but called SQL Server 2005. So after a number o...

Deploy Sql Server Express DB to Sql Server Express
I have developed by webite with Visual Studio 2005 and sql server express. I'm trying to deploy my website to a VPS with sql server express running on it I ftp'd the App_Data folder to the remote via the 'copy web site' Everything seemed okay until I started trying to run more complex database operations using stored procedures and transactions. It appears that the schema is messed up because when defining the parameters for a stored procedure, upon ExecuteNonQuery I get the error that I've assigned too many parameters which I have not (since it runs fine on...

sql server and sql server express
ok i am puzzled right now....i have a web application connecting to a sql server database....i uninstalled sql server express and installed sql server 2005 full version...i changed the connection string in my application to be Data Source=SKYBANDR62;Initial Catalog=aspnetdb;Integrated Security=True and through the explorer bar i can access my database freely but when i run my application i get this error Server Error in '/' Application. -------------------------------------------------------------------------------- An error has occurred while establishing a...

Import SQL 2005 Express to SQL 2005 Server
Hi, Can anyone give me a "dummies guide" to transfering my DNN 4.0 site from my development machine, running SQL Express 2005 to my host/production server which is running SQL Server 2005? Any other general advice for transferring sites between machines? Thanks, DG ...

How to connect to my sql server express,also Pubs and northwind for sql server express
1, I have installed VWD express,sql server 2005 express.I also install management studio and adventureswork db.In the management studio I can able to connect and view adventurework db.But I can't manage to make a connection string to my db server when connecting to management studio server name is "KAMRANSHAHID\SQLEXPRESS".I wants a connection string with respect to this server.2,Is there new database for pubs and northwind for sql server 2005.Or they are of old sql server 2000.I have installed sample databases but can't find script for pubs and northwind nor it install automatically.I wan't...

SQL Server Express and SQL Server 2005
can any one tell me what the main differences are in the two editions? also can you use and express 2005 edition database on sql 2005? if not how would you do that? Tuppers Look here for a detailed comparison between the two.Yes, you can use Express databases on SQL Server 2005. Just attach it to an instance of SQL Server 2005.Is this enough information?DonDon Kiely, MCP, MCSDIn the Last Frontier, Interior AlaskaPlease post questions and replies to the forum! And remember to MARK AS ANSWER when someone definitively answers a question or resolves a problem! cheers i was told by my host t...

SQL SERVER EXPRESS versus SQL SERVER
Would anyone really use ASPNET2 Membership Services with its built in Sql Server Express database for a major, heavy traffic website? How well would sql server express handle 1 million members? Can anyone point me to an article comparing performance of full blow Sql Server with (watered down?) Sql Server Express? Seems to me you already know the answer to this question in the way you ask the question.  SQL Server express is just for normal web applications for learning/teaching and small time deployment.  Obviously by logic heavy traffic ( esp in the 1 million range even in t...

SQL Server Express
I'm developing applications with VWD Beta1 and SQLServer Express, and when its possible I'll want to publish it on the INet. I'll probably publish it in a server with SQLServer (without Express), and I want to know if I will have to change something in my code for this change. Thanks!!subgurim.net: blog de ASP.NET 2.0 con C# en castellanoes-asp.net: el portal de ASP.NET en castellano If you don't use any specific SQl 2005 Features, you should probably not need to change your code (Maybe only the connection string so it will target the other Sql Server)./Fredrik Normén - fredrikn @ tw...

Mixing SQL Server and SQL Server Express
VWD 2008 Express.  Visual Basic. I have some questions: 1.  If I create a web site that uses a local database (stored in a directory in my web site's root directory) handled by SQL Server 2008 Express, what happens when I move the site from VWD to my server?  My server has SQL Server 2005 Standard running on it.  Will my site run even if SQL Server 2008 Express is not installed on the server?  Do I need to install SQL Server 2008 Express on my server? 2.  Can my Windows 2003 Server run both SQL Server 2005 Standard and SQL Server 2008 Expre...

sql server and sql server express conflict
hey all please help me ....i have been working on this issue for 2 days i created a web application with a automatically generated security database and added tables to it and it was working fine...i had to a linked server the linked server cannot be added from sql server express so i installed the full version...it was working fine until suddenly i got this error "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed" so i searched and searched then i found out that i cannot have the two ver...

Web resources about - Importing a script into SQL Server Express - asp.net.sql-datasource

Viral Channels: Hi5 Adds Contact Importing to App Invite Flow
... social networking platform I’ve seen, hi5 announced tonight that it is adding the ability for users to invite non-hi5 friends to apps by importing ...

YouTube - iPad importing photos from floppy disk.
You are using an outdated browser, which YouTube no longer supports. Since some features on YouTube may not work, you are viewing a lightweight ...

Tony Abbott considers importing US-style school program with private industry involvement
Tony Abbott is considering an unprecedented Americanisation of the school education system with radical changes that could see HECS-style fees ...

Importing fuel will prove better for the consumer
Importing fuel will prove better for the consumer

Sydney grandmother Lorn Cheng arrested for allegedly importing heroin in 252 pellets
Brenda filed a missing persons report last Friday, concerned that her mother hadn't returned from a holiday in Cambodia when she said she would. ...

Importing more fads from failed systems
Fast-tracking talented professionals into the classroom is yet another imported fad from England and the US - both of which are failed education ...

Mark Clermont sentenced to life in jail for importing drugs worth $260 million inside road roller
A judge has praised police for preventing cocaine and methylamphetamine with a street value of $260 million reaching the streets of Sydney and ...

Hong Kong man charged with importing 150kg of crystal methamphetamine into Sydney
A Hong Kong national is charged with importing 150 kilograms of ice following a joint-agency investigation in Sydney.

Man, 91, charged with importing cocaine hidden in soap boxes into Australia
A 91-year-old Sydney man has been charged with importing cocaine hidden in soap into Australia, prompting police to warn travellers to beware ...

Adobe updates Photoshop Express for Android with blemish removal tool, RAW importing, more
Adobe has actively been rolling out new and powerful tools for mobile platforms in recent months including Lightroom Mobile for iPad followed ...

Resources last updated: 12/8/2015 6:36:43 PM