|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SPROC - Assigning query results to variable to use in another query?wall. Any help is appreciated. Within a SPROC, I need to retrieve a value from one query, assign it to a variable and use the variable in the next query. When I try to create the SPROC, I get this error: Server: Msg 116, Level 16, State 1, Procedure cspcgOCPNavBarLinks, Line 30 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Here is the code: create procedure cspcgOCPNavBarLinks @iIndividualId int, @iSiteId int as begin declare @iReturnCode int, @iError int, @strValsToSplit char(510) SET NOCOUNT ON select @iReturnCode = 0 select @strValsToSplit = vchUser6 from individual where iIndividualId = @iIndividualId select iSecurityLinkId, iSiteId, iParameterId, REPLACE(vchURL,'<individualid>',@iIndividualId), vchToolTip, vchWindowProperty, iSequenceId, tiDefault, tiAnonymous, dtInsertDate, chInsertBy, dtUpdateDate, chUpdateBy, tiRecordStatus from csSecurityLinks where tiRecordStatus = 1 and (iParameterId in (select * from fn_split(@strValsToSplit,',')) or tiDefault = 1) and iSiteId = @iSiteId order by iSequenceId select @iError = @@error if @iError <> 0 begin exec @iReturnCode = ospCheckError N'I', @iError end return @iReturnCode end GO Any help is appreciated. -Corky Can you name a single column in here rather than Selecting * ?
and (iParameterId in (select * from fn_split(@strValsToSplit,',')) or --> and (iParameterId in (select Somenamefromthetablefunction from fn_split(@strValsToSplit,',')) or HTH; Jens Suessmeyer. What is the name of the column in the table returned by fn_Split?
> and (iParameterId in (select * from fn_split(@strValsToSplit,',')) or and (iParameterId in (select [column_name] from fn_split(@strValsToSplit,',')) or --or and (iParameterId in (select c1 from fn_split(@strValsToSplit,',') as t(c1)) or AMB Show quote "Corky" wrote: > I am trying to figure out how to do this, and have run into a brick > wall. Any help is appreciated. > > Within a SPROC, I need to retrieve a value from one query, assign it to > a variable and use the variable in the next query. When I try to create > the SPROC, I get this error: > > Server: Msg 116, Level 16, State 1, Procedure cspcgOCPNavBarLinks, Line > 30 > Only one expression can be specified in the select list when the > subquery is not introduced with EXISTS. > > Here is the code: > > create procedure cspcgOCPNavBarLinks > @iIndividualId int, > @iSiteId int > as > > begin > > declare @iReturnCode int, > @iError int, > @strValsToSplit char(510) > > SET NOCOUNT ON > select @iReturnCode = 0 > > select @strValsToSplit = vchUser6 from individual where iIndividualId = > @iIndividualId > > select iSecurityLinkId, > iSiteId, > iParameterId, > REPLACE(vchURL,'<individualid>',@iIndividualId), > vchToolTip, > vchWindowProperty, > iSequenceId, > tiDefault, > tiAnonymous, > dtInsertDate, > chInsertBy, > dtUpdateDate, > chUpdateBy, > tiRecordStatus > > from csSecurityLinks > where tiRecordStatus = 1 > and (iParameterId in (select * from fn_split(@strValsToSplit,',')) or > tiDefault = 1) > and iSiteId = @iSiteId > order by iSequenceId > > select @iError = @@error > if @iError <> 0 > begin > exec @iReturnCode = ospCheckError N'I', @iError > end > > return @iReturnCode > > end > > GO > > Any help is appreciated. > > -Corky > > |
|||||||||||||||||||||||