problem in result using function.........

Last Reply on May 04, 2012 10:53 PM By Amit

Posted on May 04, 2012 08:35 AM

I hv tow table first asr having two attribute id and name

create table asr(

id int,

name varchar(30)

)

2nd table asr1 also having same attributes as shown below but id is in varchar..

create table asr1(

id varchar(30),

name varchar(30)

)

 

i hv split function which split string on the basis of any characther.....i m trying to split on the basis of  ',' for which i use qurry like this:

 

DECLARE @name SYSNAME

SELECT @name =id FROM asr1 

select a.name from asr a where convert(varchar,a.id) in

(select data from dbo.split (@name, ','))

 

But this querry split only last row as @name saves value of last row not all the rows.

how should i save result of all row in @name so that all 'name' of asr would display in o/p which satisfies the condition

 

Posted on May 04, 2012 11:16 AM

Have u checked @name and split function????


Posted on May 04, 2012 11:18 AM

give me some sample data with expecting out put so i can give u better solution


Posted on May 04, 2012 10:50 PM

select * from asr : o/p

id    Name

1amit

2sumit

3vinayak

4sonia

select * from asr1 : o/p

id          Name

1            dlf

1,2,3      mahindra

4,5      reliance

 

when i apply querry :

DECLARE @name SYSNAME

SELECT @name =id FROM asr1 

select a.name from asr a where convert(varchar,a.id) in

(select data from dbo.split (@name, ','))

o/p is

name

sonia

 

but i want o/p like this :

 

name

amit

sumit

vinayak

sonia


Posted on May 04, 2012 10:53 PM

as i said split function split variable on the basis of any character,but the problem is @name only store last value of the table