0% found this document useful (0 votes)
4 views

SQL 14

The document discusses various SQL string functions like REVERSE, REPLICATE, REPLACE, LTRIM, RTRIM, TRIM, CHARINDEX and their usage. It also discusses converting data types and formatting dates. The roles and responsibilities of a database test engineer are outlined.

Uploaded by

Pooja Rajurkar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

SQL 14

The document discusses various SQL string functions like REVERSE, REPLICATE, REPLACE, LTRIM, RTRIM, TRIM, CHARINDEX and their usage. It also discusses converting data types and formatting dates. The roles and responsibilities of a database test engineer are outlined.

Uploaded by

Pooja Rajurkar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

--reverse()

--This function reverse a string and returns result.

select REVERSE('PUNE')

--Replicate
--This function is used to reapeat a string , specified number of times.

--synatx: replicate(string , integer)

select REPLICATE('scodeen ', 5)

--10.REPLACE()
--This function is used to replace all the occrances of subtring within string with
new string.

--NOTE: Search is not a case-sensitive.

--syantx: replace('string','oldvalue','newvalue' )

select replace('scodeen','e','D')
select replace('PUNE','PU','MU')

select REPLACE ('aaaaaaaaaggggggbbbbbbbbbbffffffff','bf','56')

select replace('MUMBAI','MA','BA') --O/P - MUMBAI

select replace('MUMBAI','A','BA') --O/P - MUMBBAI

--.Convert
--Convert() function converts a value (of any type) into a specified data type.

--synatx: convert (data type [(length)],expression/col_name[(style)])

select GETDATE() --2022-09-09 05:53:29.280

--Style
--Converting datetime to character:
--Without With Input/Output Standard
--century century
--0 100 mon dd yyyy hh:mi AM/PM Default
--1 101 mm/dd/yyyy US
--2 102 yyyy.mm.dd ANSI
--3 103 dd/mm/yyyy British/French
--4 104 dd.mm.yyyy German
--5 105 dd-mm-yyyy Italian
--6 106 dd mon yyyy -
--7 107 Mon dd, yyyy -
--8 108 hh:mm:ss -
--9 109 mon dd yyyy hh:mi:ss:mmmAM (or PM) Default + millisec
--10 110 mm-dd-yyyy USA
--11 111 yyyy/mm/dd Japan
--12 112 yyyymmdd ISO
--13 113 dd mon yyyy hh:mi:ss:mmm Europe (24 hour
clock)>
--14 114 hh:mi:ss:mmm 24 hour
clock
--20 120 yyyy-mm-dd hh:mi:ss ODBC canonical (24
hour clock)
--21 121 yyyy-mm-dd hh:mi:ss.mmm ODBC canonical (24 hour
clock)
-- 126 yyyy-mm-ddThh:mi:ss.mmm ISO8601
-- 127 yyyy-mm-ddThh:mi:ss.mmmZ ISO8601
(with time zone Z)
-- 130 dd mon yyyy hh:mi:ss:mmmAM Hijiri
-- 131 dd/mm/yy hh:mi:ss:mmmAM Hijiri

LTRIM,RTRIM,TRIM
--LTRIM() : this function removes leading(left) spaces from a string

select datalength(' Scodeen ')

select datalength('Scodeen ')


select (ltrim(' Scodeen ')) as ltrims
--O/P
select datalength('Scodeen ') --'Scodeen '

--RTRIM() : This function removes trailing(right) spaces from string.


select datalength(' Scodeen')

select rtrim(' Scodeen ') as rtrims


--O/P
select datalength(' Scodeen') --'Scodeen '

--TRIM() : LTRIM() + RTRIM() :


--This function is used to remove leading(Left) as well trailing(right) spaces from
string.

select datalength(' Scodeen ')

select trim(' Scodeen ') as trims

select DATALENGTH(trim(' Scodeen ')) as trims

--CHARINDEX
--CHARINDEX() function searches for a substring in a string and returns position.
--if string is not found then it returns 0.

--synatx: charindex('substring','string',[(start)])

select CHARINDEX('@','[email protected]', 9)

select substring('[email protected]',1,9)

select len('[email protected]')

select SUBSTRING('[email protected]',CHARINDEX('@','[email protected]')
+1,LEN('[email protected]'))

--Q.HOW to find domain or server from email column? ****VVIMP*****


create table student (S_ID int , S_ANME varchar(20),email varchar(50))

insert into student values (1,'praveen','[email protected]'),


(2,'Amit','[email protected]'),
(3,'Nishan','[email protected]'),(4,'Sumit','[email protected]'),
(5,'Rohit','[email protected]')

select *,CHARINDEX('@',email)+1 as starts,LEN(email) as ends from student

select * , substring(email,CHARINDEX('@',email)+1,LEN(email)) as Domain from


student

--
===================================================================================
=
--Roles and responsibilities of database Test Engineer (Data Base Testing)
--1.Analyse the SRS documnet which is prepared by BA.

--2.Identify the test case sscenarios.

--3.Test case design

--4.Verify impact of Frontend operation to the backend operation.

--5. Verify the table names as per SRS document.


--Ex: User_Detail table name is changed to User_Details in DB against SRS.

--6.Verify structure of Table as per SRS.


--SP_HELP TABLE_NAME
--Ex: In table if data type size varies in BD against SRS document,Then will raise
defect and assigned to developer.

--7.Verify total number of columns or count the number of columns in table as per
SRS
select COUNT(*) from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'Table_Name'

--8.Verify column names and its ordinal positions in a table.


select COLUMN_NAME,ORDINAL_POSITION from INFORMATION_SCHEMA.COLUMNS where
TABLE_NAME = 'Sales'

--9.Verify constraints of table as per SRS.

--10.Verify NULL values are present or not in Table.

--11.Verify the number of records or count of records from table.

--12.Verify the duplicate records from table.

You might also like