Tags

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


SQL Puzzle | Search Only NVARCHAR Values Puzzle

In this puzzle you have to ff from NVarchar values only. If any value is inserted without N preceding then ignore it. Please check out the sample input values and sample expected output below.

Sample Input

Val
ff
K

Expected Output

Val

Script

Use below script to create table and insert sample data into it.

--

CREATE table Nvarcartemp 
(	
	Val NVARCHAR(100)
)

INSERT INTO Nvarcartemp VALUES ( N'ff') , ( 'ff' ) 
GO

INSERT INTO Nvarcartemp VALUES ('K')
GO

--

Rules/Restrictions

The solution should be should use “SELECT” statement or “CTE”.

Add your solution(s) in the comments section or send you solution(s) to pawankkmr@gmail.com

Solution – 1


--


SELECT * FROM Nvarcartemp
WHERE Val LIKE N'ff%'
COLLATE Latin1_General_BIN

--

Output

--

/*------------------------

SELECT * FROM Nvarcartemp
WHERE Val LIKE N'ff%'
COLLATE Latin1_General_BIN;
------------------------*/
Val
----------------------------------------------------------------------------------------------------
ff

(1 row(s) affected)


--

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

Enjoy !!! Keep Learning

Pawan Khowal 

Http://MSBISkills.com