SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help in creasting a procedure with cursor
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sravan.here
Starting Member

4 Posts

Posted - 04/19/2013 :  00:04:14  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 04/19/2013 :  02:58:51  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000