Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re #39 - Ignore External Tables #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alasdaircs
Copy link

Anti-Semi-Join against sys.external_tables on matching object_id to exclude External Tables
Also fix for ignoring TVFs - the [type] column is a 1 or 2 letter code, 'TF' for Table Valued Functions, whereas the [type_desc] is a brief description, 'SQL_TABLE_VALUED_FUNCTION' for Table Valued Functions.

Comment on lines +246 to +247
and obj.type <> 'TF' /* Ignore table value functions */
and not exists ( select * from sys.external_tables as et where et.object_id = obj.object_id )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the docs can be trusted it looks like external tables should have type = 'ET'?

Suggested change
and obj.type <> 'TF' /* Ignore table value functions */
and not exists ( select * from sys.external_tables as et where et.object_id = obj.object_id )
and obj.type not in ('ET'/*external table*/, 'TF'/*table-valued function*/)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs cannot be trusted. That was my first approach.

Copy link
Author

@alasdaircs alasdaircs Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

select
	obj.[name],
	obj.[type],
	obj.[type_desc]
from
	[sys].[external_tables] as et
	inner join
		[sys].[objects] as obj
	on
		obj.[object_id] = et.[object_id]
go
name type type_desc
v_matter U USER_TABLE
v_client U USER_TABLE
v_e_superc U USER_TABLE

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants