October 22, 2002 at 2:48 am
I am trying to create a new table within a new database, the reference book I have gives the instructions but suggests an error will appear if I don't first select a database. Yep, the error appears but the book doesn't inform as to how to select the database in the first place.
Any help?
October 22, 2002 at 3:17 am
How are you creating a table?
There is a drop down in Query Analyser that will probably say master.
Simon Sabin
Co-author of SQL Server 2000 XML Distilled
http://www.amazon.co.uk/exec/obidos/ASIN/1904347088
Simon Sabin
SQL Server MVP
http://sqlblogcasts.com/blogs/simons
October 22, 2002 at 3:52 am
I am using the monitor/terminal monitor, and sending the query CREATE TABLE enquiries, but I keep getting the same message "No database selected."
Is the problem that I am not creating the columns at the same time?
October 22, 2002 at 5:05 am
Try
USE DBANME
GO
Then your create
Or try CREATE TABLE dbname.dbo.tablename (....
and yes you need to specify at least one column within the CREATE TABLE statement, you can append others thru ALTER TABLE later.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
October 22, 2002 at 4:02 pm
Having recently learned SQL Server one of the first things my instructor impressed upon us was to begin each SQL session in Query Analyzer with the statement:
USE [databasename]
GO
This will save you some aggrevation in the future when you create a table in the wrong database and drive yourself crazy trying to figure out why it doesn't show in the database you intended.
It's a good habit to get into so you don't do like me and have to sort through the MASTER database to delete the tables you created that belong somewhere else.
October 22, 2002 at 6:58 pm
One of the things you can do to avoid this problem is to give yourself a default database other than master. For instance, on one particular server where I work I create a database called SandboxBrian for any testing I need to do. For that particular server, SandboxBrian is set as my default database.
K. Brian Kelley
http://www.truthsolutions.com/
Author: Start to Finish Guide to SQL Server Performance Monitoring
http://www.netimpress.com/shop/product.asp?ProductID=NI-SQL1
K. Brian Kelley
@kbriankelley
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply