Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


SQL Puzzle | Update Data that with a string contains apostrophe

Write a T-SQL that updates a column with a string that contains apostrophe. Basically we are expecting an update statement here.

For more please check out the sample input and the expected output.

Sample Inputs

column1
blah
Pawan

Expected Output

column1
/tƒÉÄk…Bz-ñõ’âÜ(sÀ\ÿ$K’ylôû
Pawan

Rules/Restrictions

  • The challenge is to do it with T-SQL statements only.
  • Add your solution(s) in the comments section or send you solution(s) to pawankkmr@gmail.com

Script | use below script to create table and insert some sample data


--

CREATE TABLE tests
(
	column1 VARCHAR(MAX)
)
GO

INSERT INTO tests VALUES ('blah'),('Pawan')

--

SOLUTION – 1


--

UPDATE a
SET a.column1 =  '/tƒÉÄk…Bz–ñõ''âÜ(sÀ\ÿ$K''ylôû'
FROM tests a
WHERE column1 = 'blah'

--

Add a comment if you have a solution in mind. I would love to learn it. We all need to learn.

Enjoy !!! Keep Learning

Pawan Khowal

Http://MSBISkills.com

Advertisements