Skip to content

Instantly share code, notes, and snippets.

@DCCoder90
Created August 20, 2018 13:56
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 DCCoder90/12b7c81a6ec4df961074cea41b35849c to your computer and use it in GitHub Desktop.
Save DCCoder90/12b7c81a6ec4df961074cea41b35849c to your computer and use it in GitHub Desktop.
Get fully qualified object name from object id
create function dbo.getFullyQualifiedName(
@objectid int
) returns sysname
begin
declare @fqn sysname
select
@fqn = CONCAT(
QUOTENAME(@@SERVERNAME), '.',
QUOTENAME(DB_NAME()), '.',
QUOTENAME(SCHEMA_NAME([schema_id])),'.',
QUOTENAME([name])
)
from sys.tables
where object_id = @objectid
return @fqn
end
go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment