Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

The challenge is to implement similarly functionality in TSQL, that works similar to TRANSLATE function of ORACLE.

TSQL Beginners Challenge 23 - Create SQL Server version of the ORACLE TRANSLATE function

TSQL Beginners Challenge 23 - Create SQL Server version of the ORACLE TRANSLATE function

Dec 21 2010 12:02AM by Niladri Biswas   

Introduction

In Oracle/PLSQL, the Translate function replaces a sequence of characters in a string with another set of characters. It will replace the 1st character in the string_to_replace with the 1st character in the replacement_string. Then it will replace the 2nd character in the string_to_replace with the 2nd character in the replacement_string, and so on.

For example, translate('challenge', 'aen', 'xyz'); would return 'chxllyzgy'. That is 'a' is replaced by 'x', 'e' is replaced by 'y' and 'n' by 'z'

The challenge is to implement similarly functionality in TSQL, that works similar to TRANSLATE function of ORACLE.

Sample Data

Data DataToReplace ReplacedWithData
---- ------------- ----------------
Cap  cp		       xy

Expected Results

OriginalData	TranslatedData
------------	--------------
Cap		        xay

Rules

  1. The program should run in SQL SERVER 2005 and above.
  2. The output should be in the same way as it has been shown.

Sample Script

Use the following script to generate the sample data.

DECLARE @t TABLE(
          Data VARCHAR(20),
          DataToReplace VARCHAR(100),
          ReplacedWithData VARCHAR(100)
)
INSERT INTO @t 
SELECT 'Cap','cp','xy'

SELECT * FROM @t

Restrictions

  1. The solution should be a single query that starts with a "SELECT" or “;WITH”.

Notes

Tags:Puzzles, TSQL Beginners Challenge, TC, TSQL Beginners Challenge 23

Niladri Biswas
7 · 21% · 6720
TSQL Beginners Challenge 23 - Create SQL Server version of the ORACLE TRANSLATE function , 5.0 out of 5 based on 9 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]