String Functions in SQL Server part-V || SPACE, STR, STUFF, SUBSTRING functions in SQL

Опубликовано: 05 Октябрь 2016
на канале: Softtech forum
291
2

This video will provide you the details of each string functions in SQL Server 2014. I'll be walking through each and every kinds of build in function which are available in SQL Server in my next videos.


Previous video for more String Functions

String Function Part I

https://www.youtube.com/watch?v=6cgn4...

String Function Part II

https://www.youtube.com/watch?v=RmyT8...

String Function Part III

https://www.youtube.com/watch?v=lQVnQ...

String Function Part IV

   • String Functions in SQL Server part-I...  

*****************************************************************************************

SPACE (Transact-SQL)

Returns a string of repeated spaces.

 Syntax

SPACE ( integer_expression )

 Arguments
integer_expression
Is a positive integer that indicates the number of spaces. If integer_expression is negative, a null string is returned.

 Return Types
varchar

STR (Transact-SQL)

Returns character data converted from numeric data.

 Syntax

STR ( float_expression [ , length [ , decimal ] ] )

 Arguments
float_expression
Is an expression of approximate numeric (float) data type with a decimal point.
length
Is the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
decimal
Is the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.

 Return Types
varchar


STUFF (Transact-SQL)

The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.

 Syntax

STUFF ( character_expression , start , length , replaceWith_expression )

 Arguments
character_expression
Is an expression of character data. character_expression can be a constant, variable, or column of either character or binary data.
start
Is an integer value that specifies the location to start deletion and insertion. If start or length is negative, a null string is returned. If start is longer than the first character_expression, a null string is returned. start can be of type bigint.
length
Is an integer that specifies the number of characters to delete. If length is longer than the first character_expression, deletion occurs up to the last character in the last character_expression. length can be of type bigint.
replaceWith_expression
Is an expression of character data. character_expression can be a constant, variable, or column of either character or binary data. This expression will replace length characters of character_expression beginning at start.

 Return Types
Returns character data if character_expression is one of the supported character data types. Returns binary data if character_expression is one of the supported binary data types.




SUBSTRING (Transact-SQL)

Returns part of a character, binary, text, or image expression in SQL Server.

 Syntax

SUBSTRING ( expression ,start , length )

 Arguments
expression
Is a character, binary, text, ntext, or imageexpression.
start
Is an integer or bigint expression that specifies where the returned characters start. If start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length- 1 or 0. If start is greater than the number of characters in the value expression, a zero-length expression is returned.
length
Is a positive integer or bigint expression that specifies how many characters of the expression will be returned. If length is negative, an error is generated and the statement is terminated. If the sum of start and length is greater than the number of characters in expression, the whole value expression beginning at start is returned.

 Return Types
Returns character data if expression is one of the supported character data types. Returns binary data if expression is one of the supported binary data types. The returned string is the same type as the specified expression with the exceptions shown in the table.
Specified expression Return type
char/varchar/text varchar
nchar/nvarchar/ntext nvarchar
binary/varbinary/image varbinary


Смотрите видео String Functions in SQL Server part-V || SPACE, STR, STUFF, SUBSTRING functions in SQL онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Softtech forum 05 Октябрь 2016, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 29 раз и оно понравилось людям.