SQL Server Questions - sql-server

How do I rename a database in Server Explorer on Visual Studio 2008? I changed the filename using Rename on the context menu, but that just changed the filename, not the name in SQL Server (2005 Express).
Also, is there an easy-to-use management tool like PHP MyAdmin that I can use? Or is it easier to just use VS 2008 Server Explorer?
Thanks!

Find SQL Management Studio Express 2005 for all your common tasks in dealing with the database. You'll find it more fully-featured than Visual Studio, and provides the functionality you're used to from PhpMyAdmin.
To rename your database, create a new query, either in VS or SSMS:
EXEC sp_renamedb 'oldDB_Name', 'newDB_Name'

Related

Visual studio 2012 express. Generate create database sql script like in PHP myAdmin

I have a sql database opened in Visual Studio 2012 express database explorer and would like to generate create table sql script for the entire database.
In PHP myAdmin there is such a functions but can't find it in VS 2012 express. If you open table for table the create table script is displayed and can be copied one by one but there seem to be no such function when selecting multiple tables or whole database.
Does anyone know if it's possible in VS 2012 Express?
Use SQL Server Management Studio Express.

SQL LocalDB Open in SQL Mgmt Studio Run Script

I created a new LocalDB database from Visual Studio in my WPF project. Now I'd like to run a SQL Script to create all the tables in it. But I can't find how I can open the database with SQL Management Studio? Is it supposed to work like an .sdf file where you can browse to open the database?
Thanks
You must install SQL Server 2012 Management Studio (Express) as described here: http://blogs.msdn.com/b/sqlexpress/archive/2011/10/27/net-framework-4-now-supports-localdb.aspx - download location: http://www.microsoft.com/download/en/details.aspx?id=29062

Suggestions for SQL Server GUI?

I just downloaded SQL Server 2005 Express edition. I was hoping it would come with a GUI to let me design my tables and such, but it doesn't. I'm working with ColdFusion/CF Builder here, so I don't really want one that integrates into Visual Studio. Also, it would be helpful if it has the option to connect to a remote database too. Suggestions?
SQL Server Management Studio Express should have been installed with your download. If not, you can get it here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&displaylang=en
Consider using the latest version of SQL Server Express (2008), which can be found here:
http://www.microsoft.com/express/Database/
The path for SSMS in the 2008 edition is
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
I would imagine that on 2005 the path will be the same but replace the 100 with 90. If it is not there then you can redownload it and add it to your instalation

Importing a MDF file into SQL Server 2008?

I have inherited a VB.net web app that I'm making some changes on. I'm perfectly capable with the programming side (VB and MSSQL) but I'm getting lost with the tools. I was given a zip file of the code and everything. I opened the sln file in Visual Studio 2005 and it worked fairly easily with little modification.
Running the app works perfectly. Problem is, I need to write some new SPs so need the database admin. SQL Server 2008 Express is installed but it doesn't see any database and I have no idea how to import it.
I have a folder App_Data in the project with the file ASPNETDB.MDF. Opening this in VS gived the error:
This server version is not supported. You must have Microsoft SQL Server 2005 Beta 2 or later.
Any ideas where to go from here?
You need to get Sql Server Management Studio. From there you should be able to connect to the instance of Sql Server Express running on your system and tell it to attach to the .mdf file. This will allow you to use that database from withing sql server and management studio, and you will be able to add your stored procedure. Just remember to detach again when you're done, or you won't be able to use the mdf file as you expect from your app.
Visual Studio uses SMO 2005 to connec to to SQL. The SMO 2005 will not connect to SQL 2008 by design. You need to either upgrade VS to VS 2008, or downgrade Express to Express 2005.
You can't attach mdf file made in SQL Server 2005 to a SQL Server 2008 instance. What you need is to install SQL Server 2005 Express, attach this file, backup database, then restore it on 2008 Server instance and detach the database. You will get properly created for 2008 Server mdf.

Configure VS2008 to create SQL Server databases instead of SQL Server Express?

Probably asked and answered before, but difficult to search for.
In VS2008 when you right-click App_Data folder and create new database, it attempts to create a SQL Server Express database. Well I have SQL Server 2005 Standard installed and have thus uninstalled Express. How do I get VS2008 configured to know I want SQL Server databases (NOT Express) created?
SQL Server Express databases are SQL Server databases and vice-versa. While is true that the SQL Server 2008 database files format is different from SQL Server 2005 one, whthin the same version (2005, 2005 SP1, 2005 SP2, 2008 , 2008 SP1 etc etc) all SKUs (Express, Standard, Exnterprise etc) have all the same datbase format.
Yout Visual Studio tools are guiding you down the wrong path. You should not use the Solution Explorer to add a database to the App_Data folder. Instead you should use the Server Explorer tool (menu View/Server xplorer or press Ctrl+W,L) and connect to your SQL Server 2005 instance. Then use the Server Explorer tool to explore the database. To connect to the database from your solution, add a connection string to the web.config file.
While you can manage the database objects from the Server Explorer, thar is a horrible way to do it and will cause only pain on the long run. You should instead create deployment scripts with DDL statements and run those scripts when the solution is deployed. This way your database metadata is part of your source control and you can keep track of application database versions, see Version Control and your Database.

Resources