
-- SQLAzureMWParseTSQL TSQL Output File:
-- Generated at: 3/1/2014 3:07:23 PM

if not exists (select column_name from INFORMATION_SCHEMA.columns where table_name = '{objectQualifier}tblNaDevEventsUsersSignedUpAddress' and column_name = 'companyName')
 begin
   alter table {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] add companyName nvarchar(255) null
 end
GO

if not exists (select column_name from INFORMATION_SCHEMA.columns where table_name = '{objectQualifier}tblNaDevEventsUsersSignedUpAddress' and column_name = 'mobileNumber')
 begin
   alter table {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] add mobileNumber nvarchar(255) null
 end
GO

if not exists (select column_name from INFORMATION_SCHEMA.columns where table_name = '{objectQualifier}tblNaDevEventsUsersSignedUpAddress' and column_name = 'faxNumber')
 begin
   alter table {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] add faxNumber nvarchar(255) null
 end
GO


alter procedure {databaseOwner}{objectQualifier}usp_insertUserSignUpToEventAddress
(
 @address1 nvarchar(255),
 @address2 nvarchar(255),
 @city nvarchar(255),
 @region nvarchar(255),
 @country nvarchar(255),
 @postcode nvarchar(255),
 @phone nvarchar(255),
 @firstname nvarchar(255),
 @surname nvarchar(255),
 @emailAddress nvarchar(255),
 @companyName nvarchar(255),
 @mobileNumber nvarchar(255),
 @faxNumber nvarchar (255)
)

as

set nocount on
  
	insert into {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] (address1,address2,city,region,country,postcode,phone,firstName,surname,emailAddress,companyName,mobileNumber,faxNumber)

	values (@address1,@address2,@city,@region,@country,@postcode,@phone,@firstName,@surname,@emailAddress,@companyName,@mobileNumber,@faxNumber)
	
	SELECT SCOPE_IDENTITY()
			
	return

GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}tblNaDevEventCustomControls]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table {databaseOwner}[{objectQualifier}tblNaDevEventCustomControls]
GO

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE {databaseOwner}[{objectQualifier}tblNaDevEventCustomControls](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[controlName] [nvarchar] (255) not null,
	[controlLocation] [ntext] not null
 CONSTRAINT [PK_{objectQualifier}tblNaDevEventCustomControls] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF)
)

GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}usp_nadev_EventControl_Get]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure {databaseOwner}[{objectQualifier}usp_nadev_EventControl_Get]
GO

create procedure {databaseOwner}[{objectQualifier}usp_nadev_EventControl_Get]
(
 @controlName nvarchar(255)
)

as

	select * from {databaseOwner}[{objectQualifier}tblNaDevEventCustomControls] 
		where controlName = @controlName

return

GO

if exists (select * from dbo.sysobjects where id = object_id(N'{databaseOwner}[{objectQualifier}usp_nadev_Events_User_Address_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
	drop procedure {databaseOwner}[{objectQualifier}usp_nadev_Events_User_Address_Update]
GO

create procedure {databaseOwner}[{objectQualifier}usp_nadev_Events_User_Address_Update]
(
 @addressId int,
 @address1 nvarchar(255),
 @address2 nvarchar(255),
 @city nvarchar(255),
 @region nvarchar(255),
 @country nvarchar(255),
 @postcode nvarchar(255),
 @phone nvarchar(255),
 @firstname nvarchar(255),
 @surname nvarchar(255),
 @emailAddress nvarchar(255),
 @companyName nvarchar(255),
 @mobileNumber nvarchar(255),
 @faxNumber nvarchar (255)
)

as

	update {databaseOwner}[{objectQualifier}tblNaDevEventsUsersSignedUpAddress] set address1 =@address1,
																					address2 = @address2,
																					city = @city,
																					region = @region,
																					country = @country,
																					postcode = @postcode,
																					phone =@phone,
																					firstname =@firstname,
																					surname =@surname,
																					emailaddress =@emailaddress,
																					companyname =@companyname,
																					mobilenumber=@mobilenumber,
																					faxnumber =@faxnumber

																					where addressid =@addressid

return

GO
