Skip to content

Instantly share code, notes, and snippets.

@naradae
Last active December 6, 2021 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naradae/cd8cec030cf1db9b8d64bd5a0cb64907 to your computer and use it in GitHub Desktop.
Save naradae/cd8cec030cf1db9b8d64bd5a0cb64907 to your computer and use it in GitHub Desktop.
SQL Metadata Queries
select [App ID], Name, Publisher
from [NAV App Installed App]
/*
- Update the LIKE expression to wild card search for specific tables
*/
SELECT app.Name as [App Name], app.Publisher as [App Publisher], t.name as [Table Name], c.name as [Column Name], ty.name as [Type], c.max_length as [Max Length]
FROM sys.tables t
INNER JOIN sys.columns c ON c.object_id = t.object_id
INNER JOIN sys.types ty ON ty.user_type_id = c.user_type_id
INNER JOIN [NAV App Installed App] app
ON app.[App ID] = RIGHT(t.name, 36)
WHERE t.name LIKE 'Cronus%Sales Line%'
AND t.name LIKE REPLACE('%00000000-0000-0000-0000-000000000000', '0', '[0-9a-fA-F]')
ORDER BY t.name, c.column_id
/*
- Update the LIKE expression to wild card search for specific tables
*/
SELECT app.Name as [App Name], app.Publisher as [App Publisher], t.name as [Table Name]
FROM sys.tables t
INNER JOIN [NAV App Installed App] app
ON app.[App ID] = RIGHT(t.name, 36)
WHERE t.name LIKE '%Sales Line%'
AND t.name LIKE REPLACE('%00000000-0000-0000-0000-000000000000', '0', '[0-9a-fA-F]')
ORDER BY t.name
/*
- Update the LIKE expression to wild card search for specific tables
*/
SELECT name
FROM sys.tables
WHERE name LIKE '%Sales Line%'
ORDER BY name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment