dimanche 17 juillet 2016

SQL Validating a string variable

Using SQL Scripts, I need to validate Comma Separate value. How should i validate the String Variable ?

Validation should be both Right / Left Trim for each value and there should not be any special characters such as Comma or Period for the last value.

 create table #test
 (col varchar(100))

 insert into #test values
 ('1,2'),
 ('1,2,'),
 ('1,'),
 ('1,2,3,4,5')


 select * from #test

In the above query, for the second value - Expected Result is 1,2 In the above query, for the Third value - Expected Result is 1

Aucun commentaire:

Enregistrer un commentaire