Created
August 20, 2018 13:56
-
-
Save DCCoder90/12b7c81a6ec4df961074cea41b35849c to your computer and use it in GitHub Desktop.
Get fully qualified object name from object id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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