Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL programming assistance

Author  Topic 

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-18 : 06:39:09
Hello,

I'm quite new to SQL programming and have a simple question. I have received the Command(s) completed successfully message without any database grids showing up in the messages screen. How can I get the database to display? My query is displayed below. Any help would be greatly appreciated.

 CREATE DATABASE KudlerFF;

CREATE TABLE Department
(
dname varchar(100) NOT NULL,
dnumber int NOT NULL, PRIMARY KEY(dnumber)
)
Insert Into Department(
dname,
dnumber
)

Values
('Research',1001),
('Accounting',1002),
('Manufacturing',1003),
('Human Resources',1004)

CREATE TABLE Employee
(
fname varchar(100) NOT NULL,
lname varchar(100) NOT NULL,
ssn int NOT NULL,
salary int NOT NULL,
superssn int NOT NULL,
dno int NOT NULL,
PRIMARY KEY(ssn),
FOREIGN KEY(dno)references Department(dnumber)
);

Insert Into Employee(
fname,
lname,
ssn,
salary,
superssn,
dno
)

values
('Eileen','MacAdoo',12345987,65000,12345987,1004),
('Nora','Watkins',45123987,35500,12345987,1001),
('Mary Anne','Lazarro',32145878,60000,12345987,1003),
('Clara','Thompson',03412344,53000,12345987,1003),
('Raymond','Thompson',02932455,22200,12345987,1002),
('Ziggy','Gravellese',45698755,35000,12345987,1002),
('Frankie','Thompson',32425444,17500,12345987,1001),
('Jeanne','Dyer',52455666,43000,12345987,1001),
('Tony','Aero',52432455,20000,12345987,1003),
('Jonathon','Gravellese',98765422,52300,12345987,1003)

CREATE TABLE Project
(
pname varchar(100) NOT NULL,
pnumber int NOT NULL,
dnum int NOT NULL,
UNIQUE(pname),
PRIMARY KEY(pnumber),
FOREIGN KEY(dnum)references Department(dnumber));

Insert Into Project(
pname,
pnumber,
dnum
)

values
('projectA',222,1001),
('projectB',333,1003),
('projectC',122,1003),
('projectD',232,1002),
('projectE',244,1004),
('projectF',400,1002)

CREATE TABLE Works_On
(
essn int NOT NULL,
pno int NOT NULL,
PRIMARY KEY(essn,pno),
FOREIGN KEY(essn)references Employee(ssn),
FOREIGN KEY(pno)references Project(pnumber));

Insert Into Works_On(
essn,
pno
)
values
(45123987,222),
(45123987,333),
(45123987,244),
(03412344,222),
(03412344,122),
(12345987,400),
(12345987,244),
(02932455,222),
(02932455,400),
(32425444,400),
(32425444,333),
(32425444,244),
(98765422,122),
(98765422,244)

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-07-18 : 07:55:35
make sure you run everything in same database. if i run your script, i get the result:
(4 row(s) affected)
(10 row(s) affected)
(6 row(s) affected)
(14 row(s) affected)

and tables are full.

where is the problem?
Go to Top of Page

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-18 : 08:19:18
The problem is that I am not getting any errors and not tables displayed. Isn't this supposed to happen?
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-07-18 : 09:35:55
can you create new database from scratch and run upper queries?
what are your permissions against the database/server?

which version are you using?
Go to Top of Page

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-18 : 09:47:23
Im running SQL Server Management Studio 2008 with administrator access. I tried running new queries and it gave me the same answer.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-18 : 10:08:38
what you have there is query that
1. create database
2. create table
3. insert records into the table

These query does not return any result except just the number of rows affected.

quote:
I have received the Command(s) completed successfully message without any database grids showing up in the messages screen. How can I get the database to display?

To retrieve the records, you will need to use SELECT query, example

SELECT *
FROM Employee



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

hybridoutlaw
Starting Member

12 Posts

Posted - 2010-07-18 : 10:58:53
That was what I needed. Many thanks!
Go to Top of Page
   

- Advertisement -