dbo.GetLicenseIdBySiteUrl.StoredProcedure.sql
3.24 KB
USE [AIADatabaseV5]
GO
/****** Object: StoredProcedure [dbo].[GetLicenseIdBySiteUrl] Script Date: 02/06/2018 10:49:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <magicsw>
-- Create date: <16/02/2010>
-- Description: <Fetch all the module list>
-- =============================================
CREATE PROCEDURE [dbo].[GetLicenseIdBySiteUrl]
-- Add the parameters for the stored procedure here
@sLicenseAccount varchar(100), @iEditionId int
AS
BEGIN
IF 1=0 BEGIN
SET FMTONLY OFF
END
SELECT distinct Site.Id,
ISNULL(SUBSTRING(REPLACE(REPLACE(REPLACE(Site.SiteIP+'/','www.',''),'http://',''),'https://',''),0,
CHARINDEX('/',REPLACE(REPLACE(REPLACE(Site.SiteIP+'/','www.',''),'http://',''),'https://',''))),'') as SiteIp,
ISNULL(SUBSTRING(REPLACE(REPLACE(REPLACE(Site.SiteIPTo+'/','www.',''),'http://',''),'https://',''),0,
CHARINDEX('/',REPLACE(REPLACE(REPLACE(Site.SiteIPTo+'/','www.',''),'http://',''),'https://',''))),'') as SiteIPTo,
ISNULL(SUBSTRING(REPLACE(REPLACE(REPLACE(Site.SiteMasterIPTo+'/','www.',''),'http://',''),'https://',''),0,
CHARINDEX('/',REPLACE(REPLACE(REPLACE(Site.SiteMasterIPTo+'/','www.',''),'http://',''),'https://',''))),'') as SiteMasterIPTo,Site.IsMaster
FROM License INNER JOIN LicenseToEdition ON License.Id = LicenseToEdition.LicenseId
INNER JOIN SiteToLicenseEdition ON LicenseToEdition.Id = SiteToLicenseEdition.LicenseEditionId
INNER JOIN Site ON SiteToLicenseEdition.SiteId = Site.Id WHERE
(License.AccountNumber = @sLicenseAccount) AND (LicenseToEdition.EditionId = @iEditionId)
END
GO