Skip to content

Instantly share code, notes, and snippets.

@ConstantineK
Last active February 5, 2019 17:04
Show Gist options
  • Save ConstantineK/4e8cddab9130138e2ab3219bc0955c70 to your computer and use it in GitHub Desktop.
Save ConstantineK/4e8cddab9130138e2ab3219bc0955c70 to your computer and use it in GitHub Desktop.
SELECT *
FROM
(
SELECT
STUFF((
SELECT '' + comp.entity_data AS [text()]
FROM (
SELECT
DISTINCT
number
FROM master..spt_values AS v
WHERE
v.number BETWEEN 1 and LEN(o.name)
) AS num
CROSS APPLY
(
SELECT
SUBSTRING(o.name, num.number, 1) AS entity_data
) AS comp
WHERE
comp.entity_data IN
(
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9'
)
FOR XML PATH('') ), 1, 0, '' ) AS res,
o.object_id
FROM sys.objects AS o
) AS f
WHERE
f.res IS NOT NULL
SELECT name, object_id
FROM sys.objects
where name like '%[0-9]%'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment