I have a rather complicated query that I need to convert to a Stored Procedure so that I can more easily call this query in an asp.net page.
The idea is to have two calander controls on the web page, and textbox/button.
Enter the name of the location and select the date range from the calander. Click the button and display the results in a GridView.
Paramaters needed are Name, StartDate and EndDate.
Here is the query
Thanks
The idea is to have two calander controls on the web page, and textbox/button.
Enter the name of the location and select the date range from the calander. Click the button and display the results in a GridView.
Paramaters needed are Name, StartDate and EndDate.
Here is the query
Code:
SELECT
(select name+','+state from [nms_cfg].[dbo].[ATCS_Group] where Group_Address = [WEA])as Wayside
,(SELECT 'G'
+SUBSTRING (CONVERT(varchar(100), CAST(WEA AS decimal(38,2))),3, 3 )
+'/'
+ SUBSTRING (CONVERT(varchar(100), CAST(WEA AS decimal(38,2))),6,3 )
) as 'Group ID'
,(SELECT [Name]+','+[State] FROM [NMS_CFG].[dbo].[Base_Equipment] where Base_Equip_Address= (select top 1 Base_Equip_Address from [NMS_CFG].[dbo].[be_xref_oa] where x_pbase = master.dbo.ufnStringToPbase([base1]) ))
+ ' ( ' + [base1] + ')' as Base1
,[SSI1]
,(SELECT [Name]+','+[State] FROM [NMS_CFG].[dbo].[Base_Equipment] where Base_Equip_Address= (select top 1 Base_Equip_Address from [NMS_CFG].[dbo].[be_xref_oa] where x_pbase = master.dbo.ufnStringToPbase([base2]) ))
+ ' ( ' + [base2] + ')' as Base2
,[SSI2]
,(SELECT [Name]+','+[State] FROM [NMS_CFG].[dbo].[Base_Equipment] where Base_Equip_Address= (select top 1 Base_Equip_Address from [NMS_CFG].[dbo].[be_xref_oa] where x_pbase = master.dbo.ufnStringToPbase([base3]) ))
+ ' ( ' + [base3] + ')' as Base3
,[SSI3]
,cast([Date_Time]as Date) as Date
FROM [NMS_RT].[dbo].[RT_Group_Coverage]
order by WEA, Date_Time
Comment