Search

Monday, 17 January 2011

SQL ParseName operator function


SQL ParseName operator

Returns the specified part of an object name. The parts of an object that can be retrieved are the object name, owner name, database name, and server name.

 

Note

The PARSENAME function does not indicate whether an object by the specified name exists. PARSENAME just returns the specified part of the specified object name.

 

 

SELECTPARSENAME('myserver.AdventureWorks2008R2.dbo.Person', 1)
AS
'Object Name';

SELECT
PARSENAME('myserver.AdventureWorks2008R2.dbo.Person', 2)
AS
'Schema Name';

SELECT
PARSENAME('myserver.AdventureWorks2008R2.dbo.Person', 3)
AS
'Database Name';

SELECTPARSENAME('myserver.AdventureWorks2008R2.dbo.Person', 4)
AS
'Server Name'

No comments:

Post a Comment