Page 192 - SQL
P. 192

Select Statement :


        If we apply the following Replace function:


         SELECT
             FirstName,
             REPLACE (Address, 'South', 'Southern') Address
         FROM Employees
         ORDER BY FirstName


        Result:


          FirstName     Address


          James         Southern New York

          John          Southern Boston


          Michael       Southern San Diego


        Update Statement :


        We can use a replace function to make permanent changes in our table through following
        approach.


         Update Employees
         Set city = (Address, 'South', 'Southern');


        A more common approach is to use this in conjunction with a WHERE clause like this:


         Update Employees
         Set Address = (Address, 'South', 'Southern')
         Where Address LIKE 'South%';



        PARSENAME


        DATABASE : SQL Server

        PARSENAME function returns the specific part of given string(object name). object name may
        contains string like object name,owner name, database name and server name.


        More details MSDN:PARSENAME

        Syntax


         PARSENAME('NameOfStringToParse',PartIndex)


        Example


        To get object name use part index 1


        https://riptutorial.com/                                                                             174
   187   188   189   190   191   192   193   194   195   196   197