/*
SPACE(number) – Returns number of spaces, specified by the value argument.
*/
select fname + space(10) + lname from tblemp;
/*
PATINDEX(‘%Pattern%’, DataorColumnValue)
Returns the starting position of the first occurrence of a pattern in a specified DataorColumnValue.
It takes two arguments, the pattern to be searched and the DataorColumnValue.
PATINDEX() is similar to CHARINDEX(). With CHARINDEX() we cannot
use wildcards, where as PATINDEX() spports. If the specified pattern is not found, PATINDEX()
returns ZERO. wildcard – % it mean all */ select email,patindex(‘%.com’,email) position from tblemp where patindex(‘%.com’,email)>0; /* REPLACE(data_to_be_replace, Pattern , with_this_Value)
Replaces all occurrences of a specified string value with another string value.
Example: All .COM strings are replaced with .NET
*/ Select Email, REPLACE(Email, ‘.com’, ‘.net’) as ConvertedEmail
from tblEmp;
/*
STUFF(original_value, start, num_of_chars_to_be_remove, new_value)
STUFF() function inserts original_value, at the start position specified,
along with removing the character specified using num_of_chars_to_be_remove parameter.
Example:
Select FirstName, LastName,Email, STUFF(Email, 2, 3, ‘*****’) as StuffedEmail
From tblEmployee
*/
Select FNAME, LNAME,Email, STUFF(Email, 2,3, ‘***’) as StuffedEmail
From tblemp
select * from tblemp;
select getdate(), current_timestamp, sysdatetime(), SYSDATETIMEOFFSET(), GETUTCDATE();
— to check a value is date or not – use isdate(‘value’) function and it return 1 if value is in
–date format otherwise it return 0
select ISDATE(‘ram’), isdate(‘2024-08-24’);
–Day() – Returns the ‘Day number of the Month’ of the given date
select DAY(getdate()), month(getdate()), year(getdate());
select datename(day,getdate()), datename(weekday,getdate()), datename(month,getdate());
select datepart(day,getdate()), datepart(weekday,getdate()), datepart(month,getdate());