Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » System FunctionsRSS Feeds

PARSENAME Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4439

This article explains about PARSENAME function in sql server with examples.

PARSENAME function is used to get the specified part of an object name. Parts of an object can be object name, owner name, database name, and server name.

It does not indicate whether or not an object by the specified name exists. It returns the specified part name of the given object name.


Syntax of PARSENAME Function :

PARSENAME ( 'object_name' , object_piece )

object_name is a name of an object. It is a sysname.

object_piece is an object part to return. It is of type integer. It can have below values.

Value

Description

1

Object name

2

Owner name

3

Database name

4

Server name

 

Return type of PARSENAME function is nchar.




Examples of PARSENAME Function :

Example 1 : Use of PARSENAME function in select clause 

SELECT PARSENAME('NorthWind..Customers',3) AS DatabaseName

Output
NorthWind

Above example returns database name of specified object.
  
Share: 

 
 

Didn't find what you were looking for? Find more on PARSENAME Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of PARSENAME Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!