Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

need help in creating a procedure which uses cursor and variables Expand / Collapse
Author
Message
Posted Thursday, April 18, 2013 10:08 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, April 4, 2014 5:46 PM
Points: 12, Visits: 42
have situation where i need to create a procedure 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 are 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

in the below mentioned function SID and DOB whould be passed as a variables from the source table

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
Post #1444223
Posted Thursday, April 18, 2013 10:26 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 9:48 PM
Points: 3,636, Visits: 8,151
I wish I could help you, but I don't understand what you're trying to do.
Please take a look at the article linked in my signature to obtain better help.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1444225
Posted Friday, April 19, 2013 2:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 8:09 AM
Points: 6,750, Visits: 13,896
Luis Cazares (4/18/2013)
I wish I could help you, but I don't understand what you're trying to do.
Please take a look at the article linked in my signature to obtain better help.


It makes sense if you see this thread too, Luis.
I don't see much point in following this potential solution until others have been considered first.


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Post #1444275
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse