Sadda-shutu
Sadda-shutu

Reputation: 1309

Selecting specific row number in sql?

Is any way that I could select specified number of row in SQL Server? here i have the query the Result looking like this

select LEFT(intValue,patindex('%$*%' , intValue) -1) as ID,
   Right(intValue, (LEN(intValue) - (patindex('%$*%' , intValue) + 1)))as Data  
   from dbo.Split('1$*hi,2$*hellow, ',')

ID  |   Data
----------------
 1  |   HI  
 2  |   hellow

here i i wan to select the specific row item Data

select LEFT(intValue,patindex('%$*%' , intValue) -1) as ID,
   Right(intValue, (LEN(intValue) - (patindex('%$*%' , intValue) + 1)))as Data  
   from dbo.Split('1$*hi,2$*hellow, ',') ID=1

like where ID=1

I need Result like

Data
-----
 HI

Thanks in advance

Upvotes: 0

Views: 164

Answers (2)

MayOkba
MayOkba

Reputation: 99

select Right(intValue, (LEN(intValue) - (patindex('%$*%' , intValue) + 1)))as Data
from dbo.Split('1$*hi,2$*hellow,3$*Acronym', ',') where LEFT(intValue,patindex('%$*%' , intValue) -1) = 1

Upvotes: 1

Meysam Tolouee
Meysam Tolouee

Reputation: 579

With CTE As (
select LEFT(intValue,patindex('%$*%' , intValue) -1) as ID,
   Right(intValue, (LEN(intValue) - (patindex('%$*%' , intValue) + 1)))as Data  
   from dbo.Split('1$*hi,2$*hellow, ',')
)
Select * From CTE Where ID = 1

Upvotes: 1

Related Questions