Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help in creasting a procedure with cursor

Author  Topic 

sravan.here
Starting Member

4 Posts

Posted - 2013-04-19 : 00:04:14
Hi,
I have situatuion where i need to create a proceduer that uses another table data and fetches each table row and passes them as variables into the following user defined function (dbo.Split)

The values id,SID,DOB the getting from another table columns values

Soure table has

ID ColNAME
1 SID,DOB
2 SID,DOB
3 NAME,CITY,ZIP
4 NAME,CITY,ZIP

i need to use variables to fetch each row and pass them into the below function

select id, SID, DOB
into table1
from
(
select t.id,
c.colname,
c.colvalue
from yt t
cross apply dbo.split(t.name, t.text, ',') c
where c.colname in ('SID', 'DOB')
) src
pivot
(
max(colvalue)
for colname in (SID, DOB)
) piv;

select *
from table1


Can some one please help me

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-19 : 02:58:51
hmm...i dont think you need a cursor for this. why not do it in a set based manner?

If you tell us full requirement by means of sample data and output, we can help you out.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -