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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Saving Typing / Helping Performance in Sprocs

Author  Topic 

PiecesOfEight
Posting Yak Master

200 Posts

Posted - 2001-02-06 : 09:39:38
The following code is part of a UNION in a stored procedure. The second select is used again verbatim later on in the code. Is it possible to assign the results of that select to a variable before I do anything else, and then use it where I need it. I understand how to do this with @@Identity on inserts, but I'm confused here...Also, does the approach I'm taking cause a performance hit or is it negligible as the query is cached?



select SectionMapCoords as MapCoords,
SectionTitle as AltText,FileLink
from tblSection s
inner join tblSubSection ss
on s.SectionID = ss.FK_SectionID
inner join tblFile f
on ss.SubSectionID = f.FK_SubSectionID
where FileOrder = 1 and SubSectionOrder = 1 and SectionID <>
(
select SectionID
from tblSection s
inner join tblSubSection ss
on s.SectionID = ss.FK_SectionID
inner join tblFile f
on ss.SubSectionID = f.FK_SubSectionID
where FileLink = @FileLink
)






Edited by - PiecesOfEight on 02/06/2001 09:41:21
   

- Advertisement -