Question : How can I reduce the execution time of my SQL Server 2005 Stored procedure?

Hi,

I have the attached sql server 2005 stored procedure which takes around 100 seconds to execute. The procedure is being called from a web page through an ODBC connection that is timing out. I have tried to extend the timeout period by using the below code but this has has no effect?

<%
        server.ScriptTimeOut = 320
%>

I was wondering if I could perhaps alter my procedure to make it more efficent thus avoiding the time out?

Thanks.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
SELECT DISTINCT
			 	g.crm_group_object_id					as g_crm_group_object_id
		,		g.name							as g_name
		FROM     
				crmdb.dbo.tblA	as dp
		inner join	crmdb.dbo.tblB			as cd
			on	(
				dp.crm_contract_detail_id				= cd.crm_contract_detail_object_id
				)
			INNER JOIN	tblC				as	ct
					ON	(
						ct.crm_contract_object_id		=	cd.crm_contract_object_id
						)
		inner join	crmdb.dbo.tblD				as p
			on	p.crm_product_object_id					= dp.crm_product_object_id

			inner join	tblE					as	l
					on	(
						l.crm_license_object_id				=	dp.crm_license_object_id
					and	keys.dbo.get_mtn_flag_from_entry_pld(	l.key_keyno
										,	p.key_product
										,	getdate()
										,	dp.end_date
										,	dp.data1_mtn_paid_until
										,	ct.contract_type
										,	cd.contract_detail_type
										,	p.product_code
										,	dp.data1_mtn
										,	dp.mtn_override
										)	 				=	1
						)
			
		inner join	crmdb.dbo.tblF		as cl
			on	cd.crm_contract_object_id				= cl.crm_contract_object_id
		inner join	crmdb.dbo.tblG				as c
			on	c.crm_company_object_id					= cl.crm_company_object_id
		inner join	tblH 					as g
			on	(
				c.crm_group_object_id					= c.crm_group_object_id
			and	g.noclientlist = 0
			and	g.crm_group_object_id_merge = 0
			and 	len(g.name ) > 0
			and	g.status in ('Entered', 'Active')
			and	c.status in ('Entered', 'Active')
				)
		ORDER BY
				g.name

Answer : How can I reduce the execution time of my SQL Server 2005 Stored procedure?

Can you re-ask this in the form of a question?
Random Solutions  
 
programming4us programming4us