EDIT: The field I was trying to edit, I realized is nvarchar(max), and contains a TON of garbage data, and the extensions I'm trying to get to work are in a single role as comma separated values...it would be quite improbable to do what I am requesting. A HUGE thank you to all those that helped!
Before I ask, know that I have read-only access to the DB and cannot write to temp tables...as that was one solution I thought of...
I am using the following query currently:
USE Database
GO
DECLARE @dn VARCHAR(13)
SET @dn = '%15555555555%'
SELECT switch_extension, line_number, system_configurations.name, system_configurations.description, lines.system_id
FROM lines, system_configurations
WHERE lines.system_id=system_configurations.system_id
AND switch_extension like @dn
AND lines.status = 1
SELECT distinct CS.name, CTD.cti_data_value
FROM cti_source AS CS with (nolock)
JOIN cti_source_data AS CTD with (nolock)ON CS.cti_source_id = CTD.cti_source_id
--WHERE CS.status = 1
AND (CTD.cti_data_name = 'Agent_Ext'or CTD.cti_data_name = 'IVR_Ext')
AND CTD.cti_data_value LIKE @dn
The problem is, CTD.cti_data_value can contain ranges stored as strings instead of a new row with individual values, such as '15551112222-15551113333' instead of 15551112222, 15551112223, ...
If I query for a @dn in this range (unless the start or end of the range), I get no results (in the example above, if I searched for 15551112345, there would be no results, even though it exists in the "range").
Is there a way to change this to get min/max in this single string, then find a result between the min/max, or am I up a creek?