In SQL 2000, I'm trying to create a stored procedure that will email me the results of the following. The single quotes within the select statement are causing problems. What can I do?
set @query=
'select
P21Play.dbo.fk_temp_new_items.inv_mast_uid,P21Play.dbo.fk_temp_new_items.item_id,
P21Play.dbo.fk_temp_new_items.item_desc+' '+isnull(P21Play.dbo.fk_temp_new_items.extd_desc,''),
P21Play.dbo.fk_temp_new_items.date_created,P21Play.dbo.fk_temp_new_items.created_by
from P21Play.dbo.inv_mast
right outer join P21Play.dbo.fk_temp_new_items
on P21Play.dbo.inv_mast.item_desc+' '+isnull(P21Play.dbo.inv_mast.extended_desc,'')
= P21Play.dbo.fk_temp_new_items.item_desc+' '+isnull(P21Play.dbo.fk_temp_new_items.extd_desc,'')
group by
P21Play.dbo.fk_temp_new_items.inv_mast_uid,P21Play.dbo.fk_temp_new_items.item_id,
P21Play.dbo.fk_temp_new_items.item_desc,P21Play.dbo.fk_temp_new_items.extd_desc,
P21Play.dbo.fk_temp_new_items.date_created,P21Play.dbo.fk_temp_new_items.created_by
having count(P21Play.dbo.inv_mast.inv_mast_uid)>1'
set @query=
'select
P21Play.dbo.fk_temp_new_items.inv_mast_uid,P21Play.dbo.fk_temp_new_items.item_id,
P21Play.dbo.fk_temp_new_items.item_desc+' '+isnull(P21Play.dbo.fk_temp_new_items.extd_desc,''),
P21Play.dbo.fk_temp_new_items.date_created,P21Play.dbo.fk_temp_new_items.created_by
from P21Play.dbo.inv_mast
right outer join P21Play.dbo.fk_temp_new_items
on P21Play.dbo.inv_mast.item_desc+' '+isnull(P21Play.dbo.inv_mast.extended_desc,'')
= P21Play.dbo.fk_temp_new_items.item_desc+' '+isnull(P21Play.dbo.fk_temp_new_items.extd_desc,'')
group by
P21Play.dbo.fk_temp_new_items.inv_mast_uid,P21Play.dbo.fk_temp_new_items.item_id,
P21Play.dbo.fk_temp_new_items.item_desc,P21Play.dbo.fk_temp_new_items.extd_desc,
P21Play.dbo.fk_temp_new_items.date_created,P21Play.dbo.fk_temp_new_items.created_by
having count(P21Play.dbo.inv_mast.inv_mast_uid)>1'