-
Step 1. Find a computer in the Sieg building which has SQL Server installed
(most of the undergrad labs should have SQL Server).
-
Step 2. In Windows, goto Start, Programs, Microsoft SQL Server 7.0, Query
Analyzer.
-
Step 3. A Box labelled Connect to SQL Server should show up.
-
In the input box labelled SQL Server, type ISQL01
- Select the Use SQL Server authentication option.
- As Login Name type your group name - I'll pretend I'm a member in
HomeTeam, therefore I type HomeTeam
- As Password type HomeTeam's password (this is and should remain
secret) **** (please follow the exact
capitalization)
- Press OK
By doing the last step, you connected to the SQL Server machine called
ISQL01, using the project team's account. You will use this account to complete
your project.
- On the new opened windows, there is an option called DB with a
pull-down menu. Each team has a database dedicated to them, with the same
name as the team's name. Therefore here the HomeTeam team will make sure
that they have HomeTeam selected in that menu (this should be select
by default after you login).
- Let's create a table now. Let's call it test and let's have 2
attributes in it - name and age. The types of these fields
should perhaps be char(20) and int respectively.
create table test (name char(20), age int)
Type Ctrl-E to run the query or create statement (or click on the
little green arrow on the menu). If everything worked alright, you should
get back the ok message.
- Next, let's insert 2 rows in this table. Let's insert ("John", 21) and
("Bill", 65). Below your create statement type:
insert into test values("John", 21)
insert into test values("Bob", 45)
Now, using your mouse, select these two last insert statements (and leave
the create statement unselected). Press Ctrl-E (or click on the green
arrow). This means that you want only the selected statements to execute.
- Let's query our table now. Below type:
select * from test
Now, select the "select statement" and press Ctrl-E (or click on the green
arrow) to execute the query.
We should get back two rows - John and Bob.
-
Let's erase our table. Type:
drop table test
Select the last statement and press Ctrl-E (or green arrow) to execute it.
You should get an OK message.
-
Therefore you have a script now. Your script should look like:
create table test (name char(20), age int)
insert into test values("John", 21)
insert into test values("Bob", 45)
select * from test
drop table test
You can save this script in a file - type Ctrl-S. Later, when you want to
reuse this script you can open Query Analyzer and click on File -
Open and open your saved script. To execute the entire script, do not
select anything and press Ctrl-E (green arrow).