Use VenueTracker
Select * from Customer
for xml raw
Select * from Customer
for xml raw, elements, root('customers')
Select * from Customer
for xml raw('customer'), elements, root('customers')
Select Distinct CustomerLastName, customerEmail, ArtistName
From Customer cust
Inner join CustomerArtist custartist
on cust.CustomerID=custArtist.ArtistID
inner Join Artist art
on art.ArtistID=custartist.ArtistID
order by CustomerLastName
for xml auto, elements, root ('root')
Select * From customerArtist
Use Automart
Select * From Customer.AutoService
use VenueTracker
Create xml schema collection schema_VenueDescription
As
'<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://www.venutracker.com/description"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="venuedescription">
<xs:complexType>
<xs:sequence>
<xs:element name="header">
<xs:complexType>
<xs:sequence>
<xs:element name="datelastupdated" type="xs:string" />
<xs:element name="contactname" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="body">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>'
Alter table Venue
Drop column VenueDescription
Alter Table Venue
Add VenueDescription Xml(schema_VenueDescription)
Select * From Venue
Update Venue
Set VenueDescription ='<?xml version="1.0" encoding="utf-8"?>
<venuedescription xmlns="http://www.venutracker.com/description">
<header>
<contactname>John Doe</contactname>
<datelastupdated>2012-7-1</datelastupdated>
</header>
<body>
<description>
The Gorge Amphitheatre is located in the Columbia River in George,
Washington. It offers lawn-terrace seating. Administered by Live Nation,
it is considered one of the premier and most scenic concert locations
not just in North America, but the world.[1]
The venue has been a host to big name performers like The Who,
David Bowie, Coldplay, Tom Petty, Pearl Jam, Dave Matthews Band,
Phish, and Rush. The venue offers sweeping and
majestic views of the Columbia River as it skirts the foothills
of the Cascade Range southbound, as well as extreme eastern Kittitas
County and extreme western Grant County. It is also known for its spectacular
views of the Columbia gorge canyon (not to be confused with the
Columbia River Gorge proper, which begins several tens of miles
further downstream as the river turns west to cross through the
Cascades toward Portland and the Pacific Ocean).
</description>
</body>
</venuedescription>'
Where VenueId=2
Insert into venue( VenueName, VenueAddress1, VenueAddress2, VenueCity, VenueState, VenuePhone, VenueCapacity, VenueAgeRestriction, VenueURL, VenueDescription)
Values ('jazz Alley', null, '2033 6th Ave South', 'Seattle','WA','2065553214', 200,1,'http://jazzalley.com','<?xml version="1.0" encoding="utf-8"?>
<venuedescription xmlns="http://www.venutracker.com/description">
<header>
<datelastupdated>2012-23-1</datelastupdated>
<contactname>Jane Doe</contactname>
</header>
<body>
<description>
An intimate venue with food and drinks for viewing world renowned artists.
</description>
</body>
</venuedescription>')
use Automart
Select * From customer.AutoService
Select ServiceName, Serviceprice,
ServiceDescription.query('declare namespace d="http://www.automart.com/servicedescription"; d:servicedescription/d:parts/d:part/d:perpartprice') as parts
From Customer.AutoService
Where ServiceName='tune up'
Tuesday, July 24, 2012
XML in SQL Server
Wednesday, July 18, 2012
Reading and Writing Text files
Here is the file for writing text files. We tried to make it as generic as possible so it can be reused in a variety of contexts. One weakness of the class is that it is up to the user to call the closeFile method. A text file cannot be read or used if it is not closed
WriteFile.java
package com.spconger.www;
import java.io.*;
public class WriteFile {
private String path;
private PrintWriter writer;
public WriteFile(String path) throws IOException{
this.path=path;
createFile();
}
private void createFile() throws IOException{
FileWriter outFile = new FileWriter(path, true);
writer = new PrintWriter(outFile);
}
public void addText(String content){
writer.println(content);
}
public void closeFile(){
writer.close();
}
}
Here is the ReadFile.Java
package com.spconger.www;
import java.io.*;
public class ReadFile {
private String path;
public ReadFile(String path){
this.path=path;
}
public String getText() throws FileNotFoundException ,IOException{
String content="";
FileInputStream fstream = new FileInputStream(path);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine=br.readLine()) != null){
content += (strLine + "\n");
}
return content;
}
}
Here is the Program.java where we test our classes
package com.spconger.www;
import java.io.IOException;
public class Program {
/**
* @param args
*
*/
public static void main(String[] args) {
try {
WriteFile write = new WriteFile("email.txt");
write.addText("Steve" + ", steven.conger@seattlecolleges.edu");
write.addText("George" + ", george@gmail.com");
write.closeFile();
ReadFile read = new ReadFile("email.txt");
System.out.println(read.getText());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Tuesday, July 17, 2012
Hashing, Snapshots, Full Text Indexes
Use Automart
--inserting non english characters
--into a table
--the N stands for unicode
--the underlying type must be Nvarchar not varchar
Insert into Person(LastName, FirstName)
Values(N'κονγεροσ',N'Στεφονοσ')
--unicode character set
--1st 255 8 bits Ascii
--32000 16 bit character
-- 24 bit character
-- 32 bit character
-- 64 bit character
Select * From Person
Select * From Customer.RegisteredCustomer
--hashbytes is a function that "hashes"
--a value. You can use various hash methods
--MD5 is one
Declare @password varbinary(500)
Set @password=Hashbytes('MD5','jpass')
Select @password
--uses shai hash method
Declare @password varbinary(500)
Set @password=Hashbytes('sha1','jpass')
Select @password
--add a column to the Registered customer table
Alter table Customer.RegisteredCustomer
Add hashedPassword varbinary(500)
Select * from Customer.RegisteredCustomer
--add a hash for the first customer
Update Customer.RegisteredCustomer
Set hashedPassword=HASHBYTES('MD5','jpass')
Where RegisteredCustomerID=1
--simulate checking the hash as if
--for a login
Declare @Password Varbinary(500)
Set @password = HASHBYTES('MD5','jpass')
if Exists
(Select Hashedpassword from Customer.RegisteredCustomer
Where hashedPassword=@password)
Begin
Print 'Login successful'
End
Else
Begin
Print 'Login Failed'
End
--snapshots
--a snapshot takes a picture of a database
--at a moment in time
--it only physically stores the data if it has changed in
--the underlying database. the original form is copied to
--the snapshot
Create Database Automart_Snapshot
On
(Name ='Automart', Filename='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\Automart_Snapshot.ds')
As
Snapshot of Automart
Use Automart_Snapshot
Select * From Person
Use Automart
Delete From Person where Personkey=54
--make some changes in the underlying database and then
--compare the two database
Update Person
Set FirstName='Jason'
where personkey=1
--in an emergancy you can recover
--a database from a snapshot
use Master
Restore Database Automart from Database_Snapshot='Automart_Snapshot'
--Full Text Catalog
use Master
--add a filegroup
Alter Database Automart
Add Filegroup FullTextCatalog
use Automart
--add a table with some text
Create Table TextTest
(
TestId int identity (1,1) primary key,
TestNotes Nvarchar(255)
)
--insert text
Insert into TextTest(TestNotes)
Values('For test to be successful we must have a lot of text'),
('The test was not successful. sad face'),
('there is more than one test that can try a man'),
('Success is a relative term'),
('It is a rare man that is always successful'),
('The root of satisfaction is sad'),
('men want success')
Select * From TextTest
--create full text catalog
Create FullText Catalog TestDescription
on Filegroup FullTextCatalog
--Create a full text index
Create FullText index on textTest(TestNotes)
Key Index PK__TextTest__8CC33160412EB0B6
on TestDescription
With Change_tracking auto
--run queries on the full text catalog
--find all instances that have the word "sad"
Select TestID, TestNotes
From TextTest
Where FreeText(TestNotes, 'sad')
--do the same with successful
Select TestID, TestNotes
From TextTest
Where FreeText(TestNotes, 'successful')
Select TestID, TestNotes
From TextTest
Where Contains(TestNotes, '"success"')
--look for any words containing the letters "success"
--the * is a wildcard
Select TestID, TestNotes
From TextTest
Where Contains(TestNotes, '"success*"')
--looks for all grammatical forms of a word
Select TestID, TestNotes
From TextTest
Where Contains(TestNotes, ' Formsof (Inflectional, man)')
--finds words near another word
Select TestID, TestNotes
From TextTest
Where Contains(TestNotes, ' not near successful')
Select TestID, TestNotes
From TextTest
Where Contains(TestNotes, ' sad near successful')
Functions and A Trigger
Use VenueTracker --to do --artist take venue take Sellout --Function for sellout --function for Venue take --function for Artist take --trigger to make a list of people to notify about upcoming events Go --this function has some problems. It duplicates capacity and so gives a false --amount for shows that have multiple ticket vendors Alter Function Venue.func_SellOut (@ticketPrice decimal(5,2), @Capacity int) --these are user provided parmeters returns Decimal(9,2) --the return type for the function As --begin function Begin--functions require a begin and end statement Declare @Total Decimal(9,2) --declare a variable Set @Total= @ticketPrice * @Capacity --set the value return @Total --return it End GO Select VenueName, s.ShowID, TicketPrice, VenueCapacity, Venue.func_SellOut(TicketPrice, VenueCapacity) as Total From Venue v inner Join Show s on s.VenueID = v.VenueID inner join TicketOutlet t on t.ShowID=s.ShowID Select VenueName, s.ShowID, VenueCapacity, Sum(Venue.func_SellOut(TicketPrice, VenueCapacity) )as Total From Venue v inner Join Show s on s.VenueID = v.VenueID inner join TicketOutlet t on t.ShowID=s.ShowID Group by VenueName, s.ShowID, VenueCapacity Select * From TicketOutlet Alter Table TicketOutlet Add TotalTickets int Select * From TicketOutlet Select * From Venue Go Create Function Venue.func_CurrentSales (@Totaltickets int, @TicketsRemaining int, @TicketPrice Decimal(5,2)) Returns Decimal(9,2) As Begin Declare @TicketsSold int Set @TicketsSold=@Totaltickets-@TicketsRemaining Return @TicketsSold * @TicketPrice End --test the function Select VenueName, s.ShowID, Venue.func_CurrentSales(TotalTickets, TicketsRemaining, ticketPrice) As TotalSale From Venue v inner Join Show s On v.VenueID=s.VenueID Inner Join TicketOutlet t on s.ShowID=t.ShowID Go --this is a view using the function --it also uses a sum to combine the revenues --of more than one ticket outlet Go Create View Venue.CurrentSalesSummary As Select VenueName, s.ShowID, Sum(Venue.func_CurrentSales(TotalTickets, TicketsRemaining, ticketPrice)) As TotalSale From Venue v inner Join Show s On v.VenueID=s.VenueID Inner Join TicketOutlet t on s.ShowID=t.ShowID Group by VenueName, s.ShowID Select * From Venue.CurrentSalesSummary Where VenueName='Key Arena' go --this does the same as the view --but requires the name of a venue Create Proc Venue.usp_SalesSummary @VenueName nvarchar(255) As Select VenueName, s.ShowID, Sum(Venue.func_CurrentSales(TotalTickets, TicketsRemaining, ticketPrice)) As TotalSale From Venue v inner Join Show s On v.VenueID=s.VenueID Inner Join TicketOutlet t on s.ShowID=t.ShowID Where VenueName=@VenueName Group by VenueName, s.ShowID Exec Venue.usp_SalesSummary 'Columbia Gorge' --lets do a trigger --Trigger will be triggered whenever there is an insert on the show table --and it will make a table of people to be notified of upcoming events --check the artistid and see if it matches any artistid in CustomerArtist Table where the ArtistAlert is set to true --create a table of people to be alterted which will consist of the customer email, the artist name and the showvenue and date Go Create trigger tr_NotifyCustomers on Show --the table the trigger applies to For Insert -- the even As Declare @ArtistID int --inserted is a table that exists in the temp database --it only exists for the duration of the transaction --about a millesecond Select @ArtistID=ArtistID from inserted --check to see if someone wants to be alerted --about the artist If Exists (Select ArtistID from CustomerArtist Where ArtistID=@ArtistID And ArtistAlert=1) Begin --if someone does --check to see if our alert table exists If not Exists (Select Name from sys.tables Where name='CustomersToAlert') Begin --if it doesn't create the table Create Table CustomersToAlert ( CustomerEmail nvarchar(255), ArtistName nvarchar(255), VenueName nvarchar(255), ShowDate date, ShowTime Time ) End --end if table doesn't exist --declare the variable we will need to --insert into our table Declare @CustomerEmail nvarchar(255) Declare @ArtistName nvarchar(255) Declare @VenueName nvarchar(255) Declare @ShowDate date Declare @ShowTime time --assign values to each of the variables Select @ArtistName=ArtistName from Artist Where ArtistID = @ArtistID Select @CustomerEmail = CustomerEmail From Customer c Inner join CustomerArtist ca On c.CustomerID=ca.CustomerID where ca.ArtistID=@ArtistID And ca.ArtistAlert=1 Select @VenueName=VenueName From Venue v inner Join Inserted i on v.VenueID=i.VenueID Select @ShowDate = ShowDate, @ShowTime = ShowTime From Inserted --insert into our new alert table Insert into CustomersToAlert(CustomerEmail, ArtistName, VenueName, ShowDate, ShowTime) Values (@CustomerEmail, @ArtistName, @VenueName, @ShowDate, @ShowTime) End --/////this is the end of the trigger///--- --Test the trigger with an insert Insert into Show(VenueID, ArtistID, TourName, ShowDate, ShowTime, ShowPosition, ShowDescription) Values(3,1,'Some Kind of tour','8/12/2012','20:00:00','Headline',null) Select * from CustomersToAlert --it only inserted one value--we need to alter the trigger --to create a loop and a cursor --which will go through all the available records
Thursday, July 12, 2012
Backup and Restore
--this backs up the database Automart --the init makes it the first and allows differential backups BackUp Database Automart To Disk='C:\AutomartBackup\Automart.bak' with init --we will add a table between the initial and the differential backup Use Automart Create Table TestTable ( ID int identity(1,1) primary key, MyTimestamp DateTime ) Insert into TestTable (MyTimestamp) Values(GETDATE()) --the differential backup backs up whatever has changed --since the last backup Backup Database Automart To disk='C:\AutomartBackup\Automart.bak' with differential --we will add a couple more rows --that will be only in the log Insert into TestTable (MyTimestamp) Values(GETDATE()) use master --now we backup the log --the norecovery is required so that --we can restore the initial backup and all --the differential backups Backup log Automart to disk='C:\AutomartBackup\AutomartLog.trn' With norecovery, no_truncate --now we will restore the backups --first the initial backup --the the differential backup --then the log. the log is with recovery --to put the database back in a useable --mode Restore Database Automart From Disk ='C:\AutomartBackup\Automart.bak' with noRecovery, file=1 Restore Database Automart From Disk ='C:\AutomartBackup\Automart.bak' with noRecovery, file=2 use master Restore log Automart From Disk='C:\AutomartBackup\Automartlog.trn' with Recovery Use Automart Select * From TestTable
VenueTracker Database Script
USE [master] GO /****** Object: Database [VenueTracker] Script Date: 07/12/2012 12:20:32 ******/ /*If Exists (Select name from sys.databases Where name = 'VenueTracker') Begin Drop Database VenueTracker End*/ Go CREATE DATABASE [VenueTracker] Go USE [VenueTracker] GO /****** Object: User [VenuLogin] Script Date: 07/12/2012 12:20:32 ******/ CREATE USER [VenuLogin] FOR LOGIN [VenuLogin] WITH DEFAULT_SCHEMA=[Venue] GO /****** Object: Role [venueRole] Script Date: 07/12/2012 12:20:32 ******/ CREATE ROLE [venueRole] AUTHORIZATION [dbo] GO /****** Object: Schema [Venue] Script Date: 07/12/2012 12:20:32 ******/ CREATE SCHEMA [Venue] AUTHORIZATION [dbo] GO /****** Object: Schema [Customer] Script Date: 07/12/2012 12:20:32 ******/ CREATE SCHEMA [Customer] AUTHORIZATION [dbo] GO /****** Object: Schema [Artist] Script Date: 07/12/2012 12:20:32 ******/ CREATE SCHEMA [Artist] AUTHORIZATION [dbo] GO /****** Object: Table [dbo].[Genre] Script Date: 07/12/2012 12:20:34 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Genre]( [GenreID] [int] IDENTITY(1,1) NOT NULL, [GenreName] [nvarchar](255) NULL, PRIMARY KEY CLUSTERED ( [GenreID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], UNIQUE NONCLUSTERED ( [GenreName] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Genre] ON INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (3, N'Alternative') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (5, N'Country') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (4, N'Easy Listening') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (2, N'Folk') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (7, N'House') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (6, N'Pop') INSERT [dbo].[Genre] ([GenreID], [GenreName]) VALUES (1, N'Rock') SET IDENTITY_INSERT [dbo].[Genre] OFF /****** Object: Table [dbo].[Venue] Script Date: 07/12/2012 12:20:34 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Venue]( [VenueID] [int] IDENTITY(1,1) NOT NULL, [VenueName] [nvarchar](255) NOT NULL, [VenueAddress1] [nvarchar](255) NULL, [VenueAddress2] [nvarchar](255) NOT NULL, [VenueCity] [nvarchar](255) NOT NULL, [VenueState] [nchar](2) NOT NULL, [VenuePhone] [nchar](10) NOT NULL, [VenueCapacity] [int] NULL, [VenueAgeRestriction] [bit] NULL, [VenueDescription] [xml] NULL, [VenueURL] [nvarchar](255) NULL, PRIMARY KEY CLUSTERED ( [VenueID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Venue] ON INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (1, N'Key Arena', NULL, N'something 1st Avenue North', N'Seattle', N'Wa', N'2065551234', 14000, 0, N'where the sonics used to play', N'http://www.arena.com') INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (2, N'Columbia Gorge', NULL, N'George Washington', N'George', N'Wa', N'2065552345', 30000, 0, N'Big place by the river', N'http://theGorge.com') INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (3, N'Tractor Tavern', NULL, N'1001 Ballard', N'Seattle', N'Wa', N'2065553456', 150, 1, N'Ballard Tavern', N'http://www.tractortavern.com') INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (4, N'Comet Tavern', NULL, N'922 Pike', N'Seattle', N'Wa', N'2065551200', 99, 1, NULL, N'http://www.cometTavern.com') INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (6, N'Nuemos', NULL, N'923 Pike', N'Seattle', N'WA', N'2065551234', 100, 1, NULL, N'http://nuemos.com') INSERT [dbo].[Venue] ([VenueID], [VenueName], [VenueAddress1], [VenueAddress2], [VenueCity], [VenueState], [VenuePhone], [VenueCapacity], [VenueAgeRestriction], [VenueDescription], [VenueURL]) VALUES (7, N'dfdsf', NULL, N'dffdadffds', N'Seatt;e', N'Wa', N'2924384577', 100, 1, NULL, N'http://www.dfds.com') SET IDENTITY_INSERT [dbo].[Venue] OFF /****** Object: Table [dbo].[Artist] Script Date: 07/12/2012 12:20:34 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Artist]( [ArtistID] [int] IDENTITY(1,1) NOT NULL, [ArtistName] [nvarchar](255) NOT NULL, [ArtistBio] [xml] NULL, [ArtistURL] [nvarchar](255) NULL, PRIMARY KEY CLUSTERED ( [ArtistID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], UNIQUE NONCLUSTERED ( [ArtistName] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Artist] ON INSERT [dbo].[Artist] ([ArtistID], [ArtistName], [ArtistBio], [ArtistURL]) VALUES (1, N'Bob Dylan', NULL, NULL) INSERT [dbo].[Artist] ([ArtistID], [ArtistName], [ArtistBio], [ArtistURL]) VALUES (2, N'Barbara Streisand', NULL, NULL) INSERT [dbo].[Artist] ([ArtistID], [ArtistName], [ArtistBio], [ArtistURL]) VALUES (3, N'Decemberists', NULL, NULL) INSERT [dbo].[Artist] ([ArtistID], [ArtistName], [ArtistBio], [ArtistURL]) VALUES (4, N'The killers', NULL, NULL) INSERT [dbo].[Artist] ([ArtistID], [ArtistName], [ArtistBio], [ArtistURL]) VALUES (5, N'Tom Petty', NULL, NULL) SET IDENTITY_INSERT [dbo].[Artist] OFF /****** Object: Table [dbo].[Customer] Script Date: 07/12/2012 12:20:34 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Customer]( [CustomerID] [int] IDENTITY(1,1) NOT NULL, [CustomerLastName] [nvarchar](255) NOT NULL, [CustomerFirstName] [nvarchar](255) NULL, [CustomerEmail] [nvarchar](255) NOT NULL, [CustomerPassword] [nvarchar](255) NOT NULL, PRIMARY KEY CLUSTERED ( [CustomerID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], UNIQUE NONCLUSTERED ( [CustomerPassword] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], UNIQUE NONCLUSTERED ( [CustomerEmail] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Customer] ON INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (1, N'Smith', N'John', N'johnsmith@msn.com', N'jspass') INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (2, N'Jones', N'Sue', N'suejones@hotmail.com', N'sjpass') INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (3, N'Grant', N'Cary', N'carygrant@gmail.com', N'cgpass') INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (4, N'Kerr', N'Debra', N'debrakerr@yahoo.com', N'dkpass') INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (5, N'Depp', N'Johnny', N'johnnydepp@aol.com', N'jdpass') INSERT [dbo].[Customer] ([CustomerID], [CustomerLastName], [CustomerFirstName], [CustomerEmail], [CustomerPassword]) VALUES (6, N'Madonna', N'', N'madonna@msn.com', N'mpass') SET IDENTITY_INSERT [dbo].[Customer] OFF /****** Object: SqlAssembly [CLRVenuetrackerExample] Script Date: 07/12/2012 12:20:35 ******/ CREATE ASSEMBLY [CLRVenuetrackerExample] AUTHORIZATION [dbo] FROM 0x4D5A90000300000004000000FFFF0000B800000000000000400000000000000000000000000000000000000000000000000000000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F6772616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A2400000000000000504500004C010300B11FFF4F0000000000000000E00002210B010800000A00000006000000000000EE290000002000000040000000004000002000000002000004000000000000000400000000000000008000000002000000000000030040850000100000100000000010000010000000000000100000000000000000000000942900005700000000400000F003000000000000000000000000000000000000006000000C000000D42800001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000080000000000000000000000082000004800000000000000000000002E74657874000000F409000000200000000A000000020000000000000000000000000000200000602E72737263000000F00300000040000000040000000C0000000000000000000000000000400000402E72656C6F6300000C0000000060000000020000001000000000000000000000000000004000004200000000000000000000000000000000D0290000000000004800000002000500BC2000001808000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B3002004800000001000011007201000070730F00000A0A00066F1000000A00066F1100000A0B0772310000706F1200000A00281300000A076F1400000A0000DE100614FE010C082D07066F1500000A00DC002A0110000002000C002A360010000000001E02281600000A2A42534A4201000100000000000C00000076322E302E35303732370000000005006C00000018020000237E0000840200003803000023537472696E677300000000BC05000084010000235553004007000010000000234755494400000050070000C800000023426C6F620000000000000002000001471402000900000000FA25330016000001000000170000000200000002000000160000000C00000001000000010000000200000000000A00010000000000060046003F0006007400620006008B0062000600A80062000600C70062000600E00062000600F900620006001401620006002F01620006006701480106007B0162000600A70194013300BB0100000600EA01CA0106000A02CA010A0066024B020A0092027C020A00B302A0020A00C5027C020A00DE02A0020A00F8024B020A0003034B02060023033F000000000001000000000001000100010010002500000005000100010050200000000096004D000A000100B4200000000086185C000E00010011005C00120019005C00120021005C00120029005C00120031005C00120039005C00120041005C00120049005C00120051005C00170059005C00120061005C001C0071005C00220079005C000E0081005C000E0089005C0012009100C0020E008900D0022C00A100E8021200A9000B033100B10014033600B9002F030E0009005C000E002000730027002E002B0044002E00130060002E001B0060002E00230066002E000B0044002E00330075002E003B0060002E004B0060002E005B0096002E0063009F002E006B00A8003C000480000001000000E011D84D00000000000028020000020000000000000000000000010036000000000002000000000000000000000001003F020000000000000000003C4D6F64756C653E00434C5256656E7565747261636B65724578616D706C652E646C6C0053746F72656450726F63656475726573006D73636F726C69620053797374656D004F626A656374007573705F56656E756553686F7773002E63746F720053797374656D2E5265666C656374696F6E00417373656D626C795469746C6541747472696275746500417373656D626C794465736372697074696F6E41747472696275746500417373656D626C79436F6E66696775726174696F6E41747472696275746500417373656D626C79436F6D70616E7941747472696275746500417373656D626C7950726F6475637441747472696275746500417373656D626C79436F7079726967687441747472696275746500417373656D626C7954726164656D61726B41747472696275746500417373656D626C7943756C747572654174747269627574650053797374656D2E52756E74696D652E496E7465726F70536572766963657300436F6D56697369626C6541747472696275746500417373656D626C7956657273696F6E4174747269627574650053797374656D2E446961676E6F73746963730044656275676761626C6541747472696275746500446562756767696E674D6F6465730053797374656D2E52756E74696D652E436F6D70696C6572536572766963657300436F6D70696C6174696F6E52656C61786174696F6E734174747269627574650052756E74696D65436F6D7061746962696C69747941747472696275746500434C5256656E7565747261636B65724578616D706C650053797374656D2E44617461004D6963726F736F66742E53716C5365727665722E5365727665720053716C50726F6365647572654174747269627574650053797374656D2E446174612E53716C436C69656E740053716C436F6E6E656374696F6E0053797374656D2E446174612E436F6D6D6F6E004462436F6E6E656374696F6E004F70656E0053716C436F6D6D616E6400437265617465436F6D6D616E64004462436F6D6D616E64007365745F436F6D6D616E64546578740053716C436F6E746578740053716C50697065006765745F506970650045786563757465416E6453656E640049446973706F7361626C6500446973706F73650000002F63006F006E007400650078007400200063006F006E006E0065006300740069006F006E003D00740072007500650000814F530065006C006500630074002000560065006E00750065004E0061006D00650020002C002000560065006E00750065004100640064007200650073007300320020002C0020004100720074006900730074004E0061006D00650020002C002000530068006F007700440061007400650020002C002000530068006F007700540069006D0065002000460072006F006D002000560065006E007500650020007600200049006E006E006500720020006A006F0069006E002000530068006F0077002000730020004F006E00200076002E00560065006E0075006500490044003D0073002E00560065006E007500650049004400200049006E006E006500720020004A006F0069006E0020004100720074006900730074002000610020004F006E00200061002E00410072007400690073007400490044003D0073002E0041007200740069007300740049004400200000000069844A87BFF2914D9B98DFD09FAA8D320008B77A5C561934E0890300000103200001042001010E042001010205200101113504200101080401000000042000124D040000125905200101124D0707031245124D021B010016434C5256656E7565747261636B65724578616D706C6500000501000000000E0100094D6963726F736F667400002001001B436F7079726967687420C2A9204D6963726F736F6674203230313200000801000701000000000801000800000000001E01000100540216577261704E6F6E457863657074696F6E5468726F7773010000000000B11FFF4F0000000002000000A2000000F0280000F00A000052534453FD583AF7F8654242B339011BDA34CF6301000000633A5C75736572735C73636F6E6765725C646F63756D656E74735C76697375616C2073747564696F20323031305C50726F6A656374735C434C5256656E7565747261636B65724578616D706C655C434C5256656E7565747261636B65724578616D706C655C6F626A5C44656275675C434C5256656E7565747261636B65724578616D706C652E706462000000BC2900000000000000000000DE290000002000000000000000000000000000000000000000000000D02900000000000000000000000000000000000000005F436F72446C6C4D61696E006D73636F7265652E646C6C0000000000FF250020400000000000000000000000000000000000000000000000000000000100100000001800008000000000000000000000000000000100010000003000008000000000000000000000000000000100000000004800000058400000980300000000000000000000980334000000560053005F00560045005200530049004F004E005F0049004E0046004F0000000000BD04EFFE0000010000000100D84DE01100000100D84DE0113F000000000000000400000002000000000000000000000000000000440000000100560061007200460069006C00650049006E0066006F00000000002400040000005400720061006E0073006C006100740069006F006E00000000000000B004F8020000010053007400720069006E006700460069006C00650049006E0066006F000000D4020000010030003000300030003000340062003000000034000A00010043006F006D00700061006E0079004E0061006D006500000000004D006900630072006F0073006F00660074000000580017000100460069006C0065004400650073006300720069007000740069006F006E000000000043004C005200560065006E007500650074007200610063006B00650072004500780061006D0070006C0065000000000040000F000100460069006C006500560065007200730069006F006E000000000031002E0030002E0034003500370036002E00310039003900320038000000000058001B00010049006E007400650072006E0061006C004E0061006D006500000043004C005200560065006E007500650074007200610063006B00650072004500780061006D0070006C0065002E0064006C006C00000000005C001B0001004C006500670061006C0043006F007000790072006900670068007400000043006F0070007900720069006700680074002000A90020004D006900630072006F0073006F0066007400200032003000310032000000000060001B0001004F0072006900670069006E0061006C00460069006C0065006E0061006D006500000043004C005200560065006E007500650074007200610063006B00650072004500780061006D0070006C0065002E0064006C006C0000000000500017000100500072006F0064007500630074004E0061006D0065000000000043004C005200560065006E007500650074007200610063006B00650072004500780061006D0070006C0065000000000044000F000100500072006F006400750063007400560065007200730069006F006E00000031002E0030002E0034003500370036002E00310039003900320038000000000048000F00010041007300730065006D0062006C0079002000560065007200730069006F006E00000031002E0030002E0034003500370036002E00310039003900320038000000000000000000000000000000000000000000002000000C000000F03900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 WITH PERMISSION_SET = SAFE GO ALTER ASSEMBLY [CLRVenuetrackerExample] ADD FILE FROM 0x4D6963726F736F667420432F432B2B204D534620372E30300D0A1A4453000000000200000200000017000000700000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF3800E0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0BCA3101380000000010000000100000000000000D00FFFF04000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000942E3101B11FFF4F01000000FD583AF7F8654242B339011BDA34CF63000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BCA310138000000001000000010000000000000FFFFFFFF040000000380000000000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F862513FC607D311905300C04FA302A1C4454B99E9E6D211903F00C04FA302A10B9D865A1166D311BD2A0000F80849BD60A66E40CF64824CB6F042D48172A7991000000000000000E9F4640B7B370B58403860A441E959FF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000480000000000000048000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FEEFFEEF01000000F000000000633A5C75736572735C73636F6E6765725C646F63756D656E74735C76697375616C2073747564696F20323031305C50726F6A656374735C434C5256656E7565747261636B65724578616D706C655C434C5256656E7565747261636B65724578616D706C655C7573705F56656E756553686F77732E63730000633A5C75736572735C73636F6E6765725C646F63756D656E74735C76697375616C2073747564696F20323031305C70726F6A656374735C636C7276656E7565747261636B65726578616D706C655C636C7276656E7565747261636B65726578616D706C655C7573705F76656E756573686F77732E63730004000000780000000100000079000000000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001BE230018000000069CE15236160CD01010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000200000001000000020000000000000079000000280000001BE230016B6FDCC9580000000100000078000000790000006500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000036002A11000000008C01000000000000480000000000000000000000010000060000000001000000007573705F56656E756553686F7773001600031104000000580100004800000000000000010000000A0024115553797374656D00120024115553797374656D2E44617461000000001A0024115553797374656D2E446174612E53716C436C69656E7400001A0024115553797374656D2E446174612E53716C54797065730000001E002411554D6963726F736F66742E53716C5365727665722E536572766572001E00201102000000010000110000000000000400435324342430303030000000160003113C000000540100004600000001000000010000001A00201100000000010000110000000000000000636F6E6E6563740016000311EC00000050010000280000000C000000010000001600201101000000010000110000000000000000636D64000200060002000600020006002E000404C93FEAC6B359D649BC250902BBABB460000000004D0044003200000004010000040000000C0000000100050002000600F20000009C000000000000000100010048000000000000000B00000090000000000000000C000080010000000D0000800C0000000E0000800D0000000F00008014000000100000801B00000011000089270000001C000080330000001E00008034000000EEEFFE8046000000EEEFFE80470000001F000080050006001000530009000A000D001C000D0036000D0047000D00310009000A00000000000000000005000600F4000000080000000100000000000000080000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF1A092FF1100000000C02000021000000010000000100000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001E002511000000000400000001007573705F56656E756553686F77730000000016002911000000000400000001003036303030303031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000FFFFFFFF1A092FF10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF77093101010000000A00008A0B006F760C0001005C000000200000002C00000084000000000000000000000016000000190000000000EEC00000000000000000FFFF000000000000FFFFFFFF00000000FFFF00000000000000000000000009009001000000000000B40000000100000038E99D09000000000000000053746F72656450726F636564757265730043444135313336460000002DBA2EF101000000000000004800000000000000000000000000000000000000020002000D01000000000100FFFFFFFF00000000480000000802000000000000FFFFFFFF00000000FFFFFFFF010001000000010000000000633A5C75736572735C73636F6E6765725C646F63756D656E74735C76697375616C2073747564696F20323031305C50726F6A656374735C434C5256656E7565747261636B65724578616D706C655C434C5256656E7565747261636B65724578616D706C655C7573705F56656E756553686F77732E63730000FEEFFEEF010000000100000000010000000000000000000000FFFFFFFFFFFFFFFFFFFF0800FFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000942E3101B11FFF4F01000000FD583AF7F8654242B339011BDA34CF63A40000002F4C696E6B496E666F002F6E616D6573002F7372632F686561646572626C6F636B002F7372632F66696C65732F633A5C75736572735C73636F6E6765725C646F63756D656E74735C76697375616C2073747564696F20323031305C70726F6A656374735C636C7276656E7565747261636B65726578616D706C655C636C7276656E7565747261636B65726578616D706C655C7573705F76656E756573686F77732E6373000400000006000000010000001E00000000000000110000000600000022000000070000000A0000000500000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D00000018000000FC000000380000009B0100000000000014010000800000005800000028000000500200002C0200002C0000003800000003000000120000000600000011000000090000000A00000007000000080000000B0000000C0000000D0000000E000000100000000F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000130000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 AS N'bin\Debug\CLRVenuetrackerExample.pdb' GO ALTER ASSEMBLY [CLRVenuetrackerExample] ADD FILE FROM 0xEFBBBF7573696E672053797374656D2E5265666C656374696F6E3B0D0A7573696E672053797374656D2E52756E74696D652E436F6D70696C657253657276696365733B0D0A7573696E672053797374656D2E52756E74696D652E496E7465726F7053657276696365733B0D0A7573696E672053797374656D2E446174612E53716C3B0D0A0D0A2F2F2047656E6572616C20496E666F726D6174696F6E2061626F757420616E20617373656D626C7920697320636F6E74726F6C6C6564207468726F7567682074686520666F6C6C6F77696E670D0A2F2F20736574206F6620617474726962757465732E204368616E6765207468657365206174747269627574652076616C75657320746F206D6F646966792074686520696E666F726D6174696F6E0D0A2F2F206173736F636961746564207769746820616E20617373656D626C792E0D0A5B617373656D626C793A20417373656D626C795469746C652822434C5256656E7565747261636B65724578616D706C6522295D0D0A5B617373656D626C793A20417373656D626C794465736372697074696F6E282222295D0D0A5B617373656D626C793A20417373656D626C79436F6E66696775726174696F6E282222295D0D0A5B617373656D626C793A20417373656D626C79436F6D70616E7928224D6963726F736F667422295D0D0A5B617373656D626C793A20417373656D626C7950726F647563742822434C5256656E7565747261636B65724578616D706C6522295D0D0A5B617373656D626C793A20417373656D626C79436F707972696768742822436F7079726967687420C2A9204D6963726F736F6674203230313222295D0D0A5B617373656D626C793A20417373656D626C7954726164656D61726B282222295D0D0A5B617373656D626C793A20417373656D626C7943756C74757265282222295D0D0A0D0A5B617373656D626C793A20436F6D56697369626C652866616C7365295D0D0A0D0A2F2F0D0A2F2F2056657273696F6E20696E666F726D6174696F6E20666F7220616E20617373656D626C7920636F6E7369737473206F662074686520666F6C6C6F77696E6720666F75722076616C7565733A0D0A2F2F0D0A2F2F2020202020204D616A6F722056657273696F6E0D0A2F2F2020202020204D696E6F722056657273696F6E0D0A2F2F2020202020204275696C64204E756D6265720D0A2F2F2020202020205265766973696F6E0D0A2F2F0D0A2F2F20596F752063616E207370656369667920616C6C207468652076616C756573206F7220796F752063616E2064656661756C7420746865205265766973696F6E20616E64204275696C64204E756D626572730D0A2F2F206279207573696E672074686520272A272061732073686F776E2062656C6F773A0D0A5B617373656D626C793A20417373656D626C7956657273696F6E2822312E302E2A22295D0D0A0D0A AS N'Properties\AssemblyInfo.cs' GO ALTER ASSEMBLY [CLRVenuetrackerExample] ADD FILE FROM 0xEFBBBF7573696E672053797374656D3B0D0A7573696E672053797374656D2E446174613B0D0A7573696E672053797374656D2E446174612E53716C436C69656E743B0D0A7573696E672053797374656D2E446174612E53716C54797065733B0D0A7573696E67204D6963726F736F66742E53716C5365727665722E5365727665723B0D0A0D0A0D0A7075626C6963207061727469616C20636C6173732053746F72656450726F636564757265730D0A7B0D0A202020205B4D6963726F736F66742E53716C5365727665722E5365727665722E53716C50726F6365647572655D0D0A202020207075626C69632073746174696320766F6964207573705F56656E756553686F777328290D0A202020207B0D0A20202020202020207573696E67202853716C436F6E6E656374696F6E20636F6E6E656374203D6E65772053716C436F6E6E656374696F6E2822636F6E7465787420636F6E6E656374696F6E3D747275652229290D0A20202020202020207B0D0A202020202020202020202020636F6E6E6563742E4F70656E28293B0D0A20202020202020202020202053716C436F6D6D616E6420636D64203D20636F6E6E6563742E437265617465436F6D6D616E6428293B0D0A202020202020202020202020636D642E436F6D6D616E6454657874203D202253656C6563742056656E75654E616D6520220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20222C2056656E7565416464726573733220220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20222C204172746973744E616D6520220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20222C2053686F774461746520220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20222C2053686F7754696D6520220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B202246726F6D2056656E7565207620220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B2022496E6E6572206A6F696E2053686F77207320220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20224F6E20762E56656E756549443D732E56656E7565494420220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B2022496E6E6572204A6F696E20417274697374206120220D0A202020202020202020202020202020202020202020202020202020202020202020202020202020202B20224F6E20612E41727469737449443D732E417274697374494420223B0D0A0D0A20202020202020202020202053716C436F6E746578742E506970652E45786563757465416E6453656E6428636D64293B0D0A0D0A20202020202020207D0D0A202020207D0D0A7D3B0D0A AS N'usp_VenueShows.cs' GO EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyProjectRoot', @value=N'c:\users\sconger\documents\visual studio 2010\Projects\CLRVenuetrackerExample\CLRVenuetrackerExample' , @level0type=N'ASSEMBLY',@level0name=N'CLRVenuetrackerExample' GO /****** Object: Table [dbo].[ArtistGenre] Script Date: 07/12/2012 12:20:35 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[ArtistGenre]( [ArtistID] [int] NOT NULL, [GenreID] [int] NOT NULL, CONSTRAINT [pk_ArtistGenre] PRIMARY KEY CLUSTERED ( [ArtistID] ASC, [GenreID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (1, 1) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (1, 2) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (1, 5) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (2, 4) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (3, 1) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (3, 3) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (4, 3) INSERT [dbo].[ArtistGenre] ([ArtistID], [GenreID]) VALUES (5, 1) /****** Object: StoredProcedure [dbo].[usp_VenueShows] Script Date: 07/12/2012 12:20:37 ******/ Go CREATE PROCEDURE [dbo].[usp_VenueShows] AS EXTERNAL NAME [CLRVenuetrackerExample].[StoredProcedures].[usp_VenueShows] GO EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFile', @value=N'usp_VenueShows.cs' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'usp_VenueShows' GO EXEC sys.sp_addextendedproperty @name=N'SqlAssemblyFileLine', @value=N'12' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'PROCEDURE',@level1name=N'usp_VenueShows' GO /****** Object: StoredProcedure [Venue].[usp_UpdateVenue] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create proc [Venue].[usp_UpdateVenue] @VenueID int, @VenueName nvarchar(255), @VenueAddress1 nvarchar(255) = null, @VenueAddress2 nvarchar(255), @VenueCity nvarchar(255) ='Seattle', @VenueState nchar(2) ='WA', @VenuePhone nchar(10), @VenueCapacity int, @VenueAgeRestriction bit =0, @VenueDescription xml=null, @VenueURL nvarchar(255) As Begin Tran Begin Try if Exists (Select VenueID from Venue Where VenueID = @VenueID) Begin Update Venue Set VenueName =@VenueName, VenueAddress1=@VenueAddress1, VenueAddress2=@VenueAddress2, VenueCity=@VenueCity, VenueState=@VenueState, VenuePhone=@VenuePhone, VenueCapacity=@VenueCapacity, VenueAgeRestriction=@VenueAgeRestriction, VenueDescription=@VenueDescription, VenueURL=@VenueURL Where VenueID = @VenueID Commit tran end Else Begin Commit Tran Print 'The Venue doesn''t exist' End End try Begin Catch Rollback Tran print Error_message() End catch GO /****** Object: Table [dbo].[Show] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Show]( [ShowID] [int] IDENTITY(1,1) NOT NULL, [VenueID] [int] NULL, [ArtistID] [int] NULL, [TourName] [nvarchar](255) NULL, [ShowDate] [date] NOT NULL, [ShowTime] [time](7) NOT NULL, [ShowPosition] [nvarchar](255) NULL, [ShowDescription] [nvarchar](max) NULL, PRIMARY KEY CLUSTERED ( [ShowID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[Show] ON INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (2, 1, 1, N'Never Ending Tour', CAST(0xED370B00 AS Date), CAST(0x07002058A3A70000 AS Time), N'Headline', N'New stuff') INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (3, 1, 5, N'free falling', CAST(0x0F380B00 AS Date), CAST(0x0700B893419F0000 AS Time), N'Headline', N'Old Stuff') INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (5, 1, 4, N'free Falling', CAST(0x0F380B00 AS Date), CAST(0x0700B893419F0000 AS Time), N'Opening', NULL) INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (6, 2, 4, N'Summer Fest', CAST(0x1D3A0B00 AS Date), CAST(0x0700B893419F0000 AS Time), N'Festival', NULL) INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (7, 2, 3, N'Summer Fest', CAST(0x1D3A0B00 AS Date), CAST(0x07002058A3A70000 AS Time), N'Festival', NULL) INSERT [dbo].[Show] ([ShowID], [VenueID], [ArtistID], [TourName], [ShowDate], [ShowTime], [ShowPosition], [ShowDescription]) VALUES (8, 3, 2, N'Odd Places', CAST(0x263A0B00 AS Date), CAST(0x0700881C05B00000 AS Time), N'Headline', NULL) SET IDENTITY_INSERT [dbo].[Show] OFF /****** Object: Table [dbo].[CustomerArtist] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[CustomerArtist]( [CustomerID] [int] NOT NULL, [ArtistID] [int] NOT NULL, [ArtistAlert] [bit] NULL, CONSTRAINT [Pk_CustomerArtist] PRIMARY KEY CLUSTERED ( [CustomerID] ASC, [ArtistID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (1, 3, 0) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (1, 5, 1) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (2, 1, 1) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (3, 1, 1) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (3, 4, 1) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (4, 5, 1) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (5, 2, 0) INSERT [dbo].[CustomerArtist] ([CustomerID], [ArtistID], [ArtistAlert]) VALUES (6, 3, 1) /****** Object: StoredProcedure [Venue].[usp_AddVenue] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE procedure [Venue].[usp_AddVenue] @VenueName nvarchar(255), @VenueAddress1 nvarchar(255) =null, @VenueAddress2 nvarchar(255), @VenueCity nvarchar(255), @VenueState nchar(2) ='WA', @VenuePhone nchar(10), @VenueCapacity int, @VenueAgeRestriction bit =0, @VenueDescription xml =null, @VenueURL nvarchar(255) AS If not Exists (Select VenueName From Venue Where VenueAddress2=@VenueAddress2 And VenueCity=@VenueCity And VenueState=@VenueState) Begin Insert into Venue(VenueName, VenueAddress1, VenueAddress2, VenueCity, VenueState, VenuePhone, VenueCapacity, VenueAgeRestriction, VenueDescription, VenueURL) Values ( @VenueName, @VenueAddress1, @VenueAddress2, @VenueCity, @VenueState, @VenuePhone, @VenueCapacity, @VenueAgeRestriction, @VenueDescription, @VenueURL) return 1 End Else Begin Print 'The venue already exists' return 0 End GO /****** Object: Table [dbo].[TicketOutlet] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[TicketOutlet]( [TicketOutletID] [int] IDENTITY(1,1) NOT NULL, [ShowID] [int] NOT NULL, [TicketOutletURL] [nvarchar](255) NOT NULL, [TicketPrice] [decimal](5, 2) NOT NULL, [TicketsRemaining] [int] NULL, CONSTRAINT [PK_Ticket] PRIMARY KEY CLUSTERED ( [TicketOutletID] ASC, [ShowID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET IDENTITY_INSERT [dbo].[TicketOutlet] ON INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (1, 2, N'http://www.Ticketmaster.com', CAST(75.00 AS Decimal(5, 2)), 7000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (3, 3, N'http://www.Ticketmaster.com', CAST(75.00 AS Decimal(5, 2)), 12000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (5, 5, N'http://www.Ticketmaster.com', CAST(75.00 AS Decimal(5, 2)), 12000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (6, 6, N'http://www.Ticketmaster.com', CAST(55.00 AS Decimal(5, 2)), 10000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (7, 7, N'http://www.Ticketmaster.com', CAST(55.00 AS Decimal(5, 2)), 10000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (8, 7, N'http://ticketsWest.com', CAST(45.00 AS Decimal(5, 2)), 2000) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (9, 8, N'http://www.Ticketmaster.com', CAST(200.00 AS Decimal(5, 2)), 40) INSERT [dbo].[TicketOutlet] ([TicketOutletID], [ShowID], [TicketOutletURL], [TicketPrice], [TicketsRemaining]) VALUES (10, 8, N'http://www.TractorTavern.com', CAST(200.00 AS Decimal(5, 2)), 20) SET IDENTITY_INSERT [dbo].[TicketOutlet] OFF /****** Object: StoredProcedure [Venue].[usp_ShowList] Script Date: 07/12/2012 12:20:37 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create proc [Venue].[usp_ShowList] @VenueID int As Select VenueName [Venue], ArtistName [Artist], TourName [Tour Name], ShowDate [Date], ShowTime [Time], ShowPosition [Position], ShowDescription [Description] From Venue v Inner join Show s On v.VenueID=s.VenueID inner join Artist a on a.ArtistID=s.ArtistID Where v.VenueID=@VenueID GO /****** Object: Default [DF__CustomerA__Artis__38996AB5] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[CustomerArtist] ADD DEFAULT ((1)) FOR [ArtistAlert] GO /****** Object: Check [ck_position] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[Show] WITH CHECK ADD CONSTRAINT [ck_position] CHECK (([ShowPosition]='festival' OR [ShowPosition]='Opening' OR [ShowPosition]='Headline')) GO ALTER TABLE [dbo].[Show] CHECK CONSTRAINT [ck_position] GO /****** Object: ForeignKey [FK_Artist] Script Date: 07/12/2012 12:20:35 ******/ ALTER TABLE [dbo].[ArtistGenre] WITH CHECK ADD CONSTRAINT [FK_Artist] FOREIGN KEY([ArtistID]) REFERENCES [dbo].[Artist] ([ArtistID]) GO ALTER TABLE [dbo].[ArtistGenre] CHECK CONSTRAINT [FK_Artist] GO /****** Object: ForeignKey [FK_Genre] Script Date: 07/12/2012 12:20:35 ******/ ALTER TABLE [dbo].[ArtistGenre] WITH CHECK ADD CONSTRAINT [FK_Genre] FOREIGN KEY([GenreID]) REFERENCES [dbo].[Genre] ([GenreID]) GO ALTER TABLE [dbo].[ArtistGenre] CHECK CONSTRAINT [FK_Genre] GO /****** Object: ForeignKey [FK__Show__ArtistID__0CBAE877] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[Show] WITH CHECK ADD FOREIGN KEY([ArtistID]) REFERENCES [dbo].[Artist] ([ArtistID]) GO /****** Object: ForeignKey [FK__Show__VenueID__0BC6C43E] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[Show] WITH CHECK ADD FOREIGN KEY([VenueID]) REFERENCES [dbo].[Venue] ([VenueID]) GO /****** Object: ForeignKey [FK__CustomerA__Artis__37A5467C] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[CustomerArtist] WITH CHECK ADD FOREIGN KEY([ArtistID]) REFERENCES [dbo].[Artist] ([ArtistID]) GO /****** Object: ForeignKey [FK__CustomerA__Custo__36B12243] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[CustomerArtist] WITH CHECK ADD FOREIGN KEY([CustomerID]) REFERENCES [dbo].[Customer] ([CustomerID]) GO /****** Object: ForeignKey [FK__TicketOut__ShowI__108B795B] Script Date: 07/12/2012 12:20:37 ******/ ALTER TABLE [dbo].[TicketOutlet] WITH CHECK ADD FOREIGN KEY([ShowID]) REFERENCES [dbo].[Show] ([ShowID]) GO
Tuesday, July 10, 2012
Add Venue Stored Procedure and Web Form
Here is the stored procedure we created in SQL Server. For this to work, there must be a schema named Venue and a role called VenueRole. The venue roll must gran exec on the Venue Schema and select and insert on the Venue table. (Sorry for naming them the same, a mental fart on my part.)
Some of the parameters have default values. this allows us to skip them. (Specifically VenueAddress1, and VenueDescription)
/*Add new a new venue Check to make sure the venue doesn't already exist */ Go --this procedure uses the venue schema --also proc is the same as procedure Create procedure Venue.usp_AddVenue @VenueName nvarchar(255), @VenueAddress1 nvarchar(255) =null, @VenueAddress2 nvarchar(255), @VenueCity nvarchar(255), @VenueState nchar(2) ='WA', @VenuePhone nchar(10), @VenueCapacity int, @VenueAgeRestriction bit =0, @VenueDescription xml =null, @VenueURL nvarchar(255) AS If not Exists (Select VenueName From Venue Where VenueAddress2=@VenueAddress2 And VenueCity=@VenueCity And VenueState=@VenueState) Begin Insert into Venue(VenueName, VenueAddress1, VenueAddress2, VenueCity, VenueState, VenuePhone, VenueCapacity, VenueAgeRestriction, VenueDescription, VenueURL) Values ( @VenueName, @VenueAddress1, @VenueAddress2, @VenueCity, @VenueState, @VenuePhone, @VenueCapacity, @VenueAgeRestriction, @VenueDescription, @VenueURL) return 1 End Else Begin Print 'The venue already exists' return 0 End Go Exec Venue.usp_AddVenue @VenueName ='Comet Tavern', @VenueAddress1=null, @VenueAddress2='922 Pike', @VenueCity='Seattle', @VenueState='Wa', @VenuePhone='2065551200', @VenueCapacity=99, @VenueAgeRestriction=true, @VenueURL='http://www.cometTavern.com' Select * From Venue Delete From Venue where VenueID=5
Next we created a web site that uses the schema. We made a form (an ugly one, to be sure) to add a new venue. It will call the stored procedure. Here is the Html and asp source code for the form
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:Label ID="Label1" runat="server" Text="Enter Venue Name"></asp:Label>
<asp:TextBox ID="txtVenueName" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Enter Venue Address"></asp:Label>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label3" runat="server" Text="Enter City"></asp:Label>
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label4" runat="server" Text="State"></asp:Label>
<asp:TextBox ID="txtState" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label5" runat="server" Text="Enter Venue Phone"></asp:Label>
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
</p>
<p>
<asp:Label ID="Label6" runat="server" Text="Enter Venue Capacity"></asp:Label>
<asp:TextBox ID="txtCapacity" runat="server"></asp:TextBox>
</p>
<p>
<asp:DropDownList ID="ddlAgeRestriction" runat="server">
<asp:ListItem Text="Choose Age Restriction" />
<asp:ListItem Text="yes" Value="1" />
<asp:ListItem Text="no" Value="0" />
</asp:DropDownList></p>
<p>
<asp:Label ID="Label7" runat="server" Text="Enter Venue URL"></asp:Label>
<asp:TextBox ID="txtUrl" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" /><asp:Label ID="lblResult" runat="server"
Text="Label"></asp:Label>
</p>
</div>
</form>
</body>
</html>
Here is the code that connects to the database and calls the stored procedure
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//ADO 1)make a connection
//command object passes the sql to the server
//get all the values from the form
//here we create a connection string that connects to the server
//it contains the name of the server, the database and login information
SqlConnection connect = new SqlConnection
("Data Source=localhost;initial catalog=VenueTracker;user=VenuLogin;password=password");
//the command object passes sql to the server
SqlCommand cmd = new SqlCommand();
//it is going to use the connect object to get to the database
cmd.Connection = connect;
//we are going to use a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
//here is the name of stored procedure
cmd.CommandText = "usp_AddVenue";
//We must provide a value for every parameter of the stored procedure
//which does not have a default value
cmd.Parameters.AddWithValue("@VenueName", txtVenueName.Text);
cmd.Parameters.AddWithValue("@VenueAddress2", txtAddress.Text);
cmd.Parameters.AddWithValue("@VenueCity", txtCity.Text);
cmd.Parameters.AddWithValue("@VenueState", txtState.Text);
cmd.Parameters.AddWithValue("@VenuePhone", txtPhone.Text);
cmd.Parameters.AddWithValue("@VenueCapacity", int.Parse(txtCapacity.Text));
cmd.Parameters.AddWithValue("@VenueAgeRestriction",int .Parse(ddlAgeRestriction.SelectedValue));
cmd.Parameters.AddWithValue("@VenueURL", txtUrl.Text);
//we open the connection
connect.Open();
//execute the stored procedure
int x=cmd.ExecuteNonQuery();
//check the results
if (x == 1)
lblResult.Text = "Venue successfully Entered";
else
lblResult.Text = "Problems abound";
connect.Close();
}
}