Professional Documents
Culture Documents
doc
1 Stored Procedures
1.1.1 In pubs db
Create a procedure to return a list of titles for a particular type (NB: if all working in
the same pubs db, make sure they put _xxx where xxx is their network user name,
onto the proc name).
Answer:
create procedure spGetTitlesForType_xxx @type char(12)
as
select title_id, title
from titles
where type = @type
go
Using it:
SpGetTitlesForType_xxx 'business'
2 Transactions
To demonstrate:
On one client, change the Implicit_Transactions setting to ON
Start an implicit transaction to update the name of a title:
update titles set title = 'The Busy Executive''s Database Guide – an update' where title_id = 'BU1032'
If other clients now try to select from the titles table, they should find that the query is
taking some time – because the transaction has a lock on the table.
Commit the transaction on the first client:
Commit tran
Page 1 of 1