Run sql script to add tables to Sql 2005 Express

Is it possible to run a sql installation script from Visual Studio 2005 and populate a Sql Server 2005 Express database? To save time (and error) I have made a sql script for creating tables and stored procedures for my web site. I could run this script from the Sql Server 2005 Express Management tool, but this tool does something to the database that result in the error "Cannot open user default database. Login failed.". After hours searching on the net I found a tip warning me not to use use the Management tool. So, are there other ways to run my sql script?

Regards, Sigurd


10/11/2007 5:34:00 PM 7760 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 15
Get it on Google Play
Get it on Apple App Store

Hi scarabee,

We can run the create table script in Visual Studio 2005 though we will get the SQL Syntax Error. For example, please refer to the following steps:

    1. Open the “Server Explorer” panel (View | Server Explorer).
    2. Connect to the database, and expand it.
    3. Right click the “Tables” node, and then select “New Query”.
    4. Click the “Close” button directly in the “Add Table” dialog.
    5. Replace the “SELECT FROM” script by our create table script.
    6. Click the “Execute SQL (Ctrl+R)” button.
    7. Visual Studio will prompt error encountered. Ignore it by clicking “OK” or “Continue”.
    8. The table can be created successfully.

However, I don’t know where you got the warning about don’t use Management Studio tool. Actually we recommend using Management Studio to manage SQL Server 2005. The error message you encountered can be cause by Login account doesn’t mapped to the special database. Please login the SQL Server with Admin account. Or you can check the “User Mapping” of the login account by the following steps:

    1. Open SQL Server Management Studio.
    2. Expand the “Security | Logins” node.
    3. Right click your login account, and then select “Properties”.
    4. Click “User Mapping” node in the left panel.
    5. Check the “Map” checkbox for special database, and grant database role membership for it.


Benson Yu
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
10/15/2007 3:18:00 AM

Great, it works! When I got the first message (error) I thought it was not possible to run queries in a query window. But how about stored procedures? I can only one create stored procedure at the time. Are there other ways to run a script that adds several at the same time?

The problem with Management Studio 2005 Express is that is adds some security settings (or something else) to the database. After I have changed one or more tables in the Management Studio I get this error "Cannot open user default database. Login failed." when I try to run my webpage in Visual Studio. Maybe you can tell me what the problem is?


10/15/2007 10:11:50 AM

I didn't see the last part of your answere. This one seems to work also. Thanks a lot!



10/15/2007 10:38:26 AM

Similar Artilces:

Visual Studio 2005 Standard with SQL Express and SQL Server 2005 Developer Edition
Hi folks,I had visual studio 2005 Standard edition (with SQL Express) running. Then I install SQL Server 2005 Developer edition.It generally worked however some part of SQL Server Developer did not work properly (namely diagrams). I browsed the internet and found something that said I should install the .NET Framework Service Pack 1. I did so. It fixed SQL Server 2005 Developer Edition however it seems to have broken portions of Visual Studio. Specifically, typed dataset. I could add a dataset however I could no longer configure or add a table adapter. Telling me the "data provider may ...

SQL Server 2005 express connectivity with Visual Studio.NET 2005
Hello I'm having a problem with the server connection and my C# code. The code executes alright but no data is entered into the database behind it.  I'm pasting the connection code over here as well. The sql commands are used in the code. I think I used the sql server mobile edition which is installed along with visual 2005. Anyone know what's wrong, and can help me out? Thanks in advance.public static void storeInDb(string trackName, string artist, string albumTitle, string year, string path, uint[] fp) { string connStr="Data Source=.\\SQLEXPRESS;At...

I cannot stop Visual Studio.NET 2005 from looking for SQL Server 2005 instead of SQL 2000
I would like to know how to set SQL2000 as the default database server when running any webapplication. I have installed Visual Studio.NET and SQL Server 2000 locally in my laptop.  But anytime I want to run a webapplication I am getting the following error:System.Data.SqlClient.SqlException was unhandled by user code  Class=20  ErrorCode=-2146232060  LineNumber=0  Message="An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server doe...

Visual Studio 2005 Express and SQL server 2005 Express
Just a question from a Microsoft Freak. Wil dotnetnuke in the nearby future support SQL 2005 Express and wil there come a "template" for modules for Visual Studio 2005 Express ? I guess that depends on what you understand by "nearby future". I think SQL 2005 Express will work with the current version already (haven't tried however) and with such a big community I think maybe someone will eventually create a template ? Geert Veenstra Well, let me be the test case. I'l try it this evening and come back to you an the answer about SQL 2005 express. About the visual...

Installing .NET Framework, Sql Server 2005 Express, and Visual Studio 2005 Professional
Will someone please offer some advice, a walkthrough, or something to help me through this?  I installed all three of these pieces (.NET, SQL Server 2005 Express, and VS 2005 Professional) onto a WinXP box.  I was unable to get it to work.  It kept throwing SQL errors when I tried to run the security setup for the Personal Website Starter Kit.  So, I uninstalled everything except .NET and reinstalled.  At this point I was able to get to the setup, but unable to add users.  It doesn't throw errors or anything, it just doesn't do anything.  I really re...

SQL Server 2005
I'm very confused.  I installed Visual Studio 2005 and thought I understood that SQL Server 2005 came with it, but it appears that it's SQL Server 2005 - Express.  Can anyone tell me what I need to do in order to get Data Transformation Services loaded or the equivalent of DTS in SQL Express?     beejay I have to say: actually SQL Express, not SQL2005 full version, comes with VS2005. To manage your SQL Express databases much easier, you can download a Management Studio Express from here: Then you can...

SQL 2005 and SQL Express 2005
Hi all, I am sure it has been asked before, but i can't find the answer anywhere in the forum... I developed an application with SQL 2005 and .Net 2005 and i wanted to know how (if it is possible) to use that database in the SQL Express 2005 (for small customers). I have the database (tables, views and stored procedures) as it is done on the SQL 2005. If i will just attach the database in SQL Express 2005 it will work or should i do something else too? Thanks a lot. (Is it possible to install both SQL 2005 and SQL Express 2005 on the same PC? I already have SQL 2005 installed). Ye...

Visual Basic .NET 2005 Express & Sql Server 2005 Express remote server
Hi,  I want to make a component library in Visual Basic.NET and connect to a remote Sql Server. When I create a new DataSet with the wizard, I can only connect to a .mdf file, but not to a Sql Server. With Visual Web Developer I can connect to a Sql server. What is the difference between these enviroments ? How can I do the same with Visual Basic.NET ?  Thanks in advance. Visual Basic .NET Express cannot connect to SQL Servers. The Visual Web Developer is the only express edition that can utilize SQL Server. You need to upgrade to Visual Studio 2005 Standard or higher.Cheers,&n...

VS 2005 SQL 2005 Express and SQL 2005 Developer Edtion
I would like to know if there are any issues having VS2005 with SQL 2005 express and SQL 2005 Developer on the same computer.  I seem to have problem performing a Remote Connection to SQL 2005 Developer.  I  have enable the protocols and enable remote connection but I still have issues conneting. Any tips or help Thanks JulioJulio D....

Visual Studio 2008 SP1
I have the developer version of SQL 2005 & SQL Server Express 2008 installed on my laptop and Visual Studio 2008 SP1 and .Net Framework 3.5 SP1 installed.    I'm learning ASP.Net MVC and want to work with a SQL Server Express 2008, but I can't connect to SQL Server Express 2008.  I first tried to ADD a SQL Server Database by adding a SQL Server Database to app_data and received the error "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly.  Then I attempted to ADD the Membership.MDF ...

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

SQL Server 2005 Express and Visual Studio 2005 Standard
Hi everyone,I am trying to connect to SQL Server 2005 Express with Advanced Services from Visual Studio 2005 Standard Edition.  I have SQL Server 2005 Standard Edition but it took up so much space and resources on my computer that I didn't want to put it back on there.  So I put the SQL Express on there and while the Management Studio application connects just fine, VS 2005 will not.  Oddly enough, VS 2005 connected just fine to SQL 2005 Standard.  I have enabled shared memory, named pipes and TCP/IP.  I have set up SQL Express to accept remote connections on named p... Award 2005 | 1st place: MSDN Professional subscription including Visual Studio 2005 and SQL Server 2005; 2nd place: new Xbox 360
We would like to introduce the 100% cost free 5.2.2 - brand new release! is a 100% cost free Enterprise CMS platform for architects and professional developers based 100% on Microsoft .NET. With the new download version we offer ... Improved user interface (thank you for feedback!) International support avaliable! New features (muitisite, permissions, authentication, newsletter, ...) Focused on software architects and professional developers Introducing Award 2005! The Award 2005 represent an opportunity ...

Sql Server 2005 Reporting Service + Visual Studio.NET 2005
Hi, Iam new 2 sql server 2005 reporting services, I created a report server project with few reports and deployed in reportserver. Everything is working fine but i want to integrate these reports to my 2005 web appliction. Through the interface i have to pass the perameters to my reports. Iam looking for help thxs in advance PradeepPradeep Reddy Take a look over here for a working example :   HTH,Suprotim Agarwal ----- Grid With Excel Capabilities | 27 GridView Tips & Tricks |...

Web resources about - Run sql script to add tables to Sql 2005 Express -

The Indian Express: Latest News, Breaking News Live, Current Headlines, India News Online
Indian Express covers latest news from India, all exclusive current headlines and India news live, including latest breaking news on business, ...

Local news, sports, obituaries, classifieds and more - Tallmadge Express
NEWARK, N.J. (AP) Gov. Chris Christie, who once famously called himself "the healthiest fat...

Hemsworth and South Elmsall Express
Congratulations, you're now registered! Let us know what news and updates you want to hear about and we'll send them straight to your inbox. ...

Sussex Express
Search continues for boy swept out to sea at... The search has continued today (Monday October 28) for the 14-year-old local boy who was swept ...

MV Colombo Express - Wikipedia, the free encyclopedia
a title it held until the Emma Mærsk was launched in 2006. Colombo Express holds 8,749 twenty-foot equivalent units (TEU), 730 refrigerated ...

Jakartans express defiance and return to work after terror attacks
It's business as usual in Indonesian capital after Thursdays terror attacks.

Fred Armisen in his feminist bookstore persona Candace Devereaux reads "Portlandia Travelogue: The Brussels ...
Downloadable free here . A literary train journey on the Brussels to Antwerp Express through the erotic world of European train stations and ...

Walmart Closing 154 Stores In U.S., Ending “Walmart Express” Experiment
Walmart’s five-year dalliance with trying to go small through new “Walmart Express” stores is apparently over. This morning, the company announced ...

Jackson Hewitt Teams Up With American Express To Target The Underbanked This Tax Season
... and underbanked, taxpayers who have their taxes prepared at Jackson Hewitt can opt to have their federal tax refund added to an American Express ...

Siberian Express Expected to Send Temperatures Plummeting
Siberian Express Expected to Send Temperatures Plummeting

Resources last updated: 1/19/2016 9:17:33 AM