Jayce Ooi’s Paradise

Photography, programming, technology, finance, anything =)
Subscribe to Jayce Ooi's Paradise feeds

LEN (Transact-SQL)

What is LEN in Transact-SQL? It will returns the number of characters of the specified string expression, excluding trailing blanks.

For example,

DECLARE @temp varchar(60);
SET @temp = ‘ABCDEF ‘;
SELECT LEN(@temp);

The returned result is ‘6′. It returns the count of 6 characters “ABCDEF”.

RTRIM (Transact-SQL)

What is the function of RTRIM? It will returns a character string after truncating all trailing blanks.

For example,

DECLARE @string_to_trim varchar(60);
SET @string_to_trim = ‘Four spaces are after the period in this sentence. ‘;
SELECT @string_to_trim + ‘ Next string.’;
SELECT RTRIM(@string_to_trim) + ‘ Next string.’;
GO

The result == “Four spaces are after the period in this sentence. Next string.“. As you can see, the 4 spaces behind the word ’sentence’ was trim off.

SUBSTRING (Transact-SQL)

SUBSTRING will return part of the original string based on the expressions.

SUBSTRING (value_expression, start_expression, length_expression)

Example code,

SELECT x = SUBSTRING(’ABCDEFGHIJ’, 3, 5);

The returned result is “CDEFG”. It will start a index ‘3′ and with length ‘5′ characters.

CHARINDEX (Transact-SQL)

What is CHARINDEX use for? It will return the starting position if the searched value is found. For example,

CHARINDEX (SearchedValue, StringToBeSeached)

StringToBeSeached == “I like to eat durian”
SearchedValue == “eat”

The result will be ‘11′. The word “eat” start on index 11.

How to delete / drop SQL table?

How to delete / drop SQL table? The following code will guide you to drop the temporary SQL table. Basically, you just need to type in ‘DROP TABLE tableName‘.

IF OBJECT_ID(N’tempdb..#temptable’, N’U') IS NOT NULL
DROP TABLE #temptable;
GO

« Older Entries  Newer Entries »

Page 3 of 10«12345»...Last »

Sponsored links

Archives

Chat Chat Chat...




Isabell Online Penang Florist

Isabell Online Penang florist

RM210 (US$63) Cash Giveaway

Community links

edensitebar.jpg
Support WWF-Malaysia

Please support me...

Recent Comments

Top Commentators