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 2005 Forums
 Transact-SQL (2005)
 Select query if record returned then show true fal

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-05-11 : 10:53:51
Is it possible i want to use this select as in query in SP, is it possible if record dataid is returned then show true otherwise false:

(select TOP 1 docid from TABLe_DocRepository where modulerecordid=RV.RevID and modulename='LM') DocID

Thank you very much for the helpful info.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-11 : 10:59:51
If exists((select TOP 1 docid from TABLe_DocRepository where modulerecordid=RV.RevID and modulename='LM')
select 'true'
else
select 'false'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2010-05-11 : 11:09:04
Thanks Madhivanan,

But how can i use the if exists condition within the select statement as an inquery:

ALTER PROCEDURE [dbo].[USP_GetLMGridRevs]
(
@LMid int
)

AS

DECLARE @ErrorCode int

SET NOCOUNT ON
SELECT @ErrorCode = @@Error
IF @ErrorCode = 0
BEGIN
SELECT RV.RevID,

rtrim(RV.RevNo) as RevNo,

RV.RevStatus,

CONVERT(varchar(10),RV.RevisionDate,101) as RevisionDate,
CONVERT(varchar(10),RV.IssuedDate,101) as IssuedDate,
CONVERT(varchar(10),RV.LoggedDate,101) as LoggedDate,
PV.PValue from TAB_ccsNetDMRevision RV, TAB_ccsNetPicklistValue PV
Where RV.LMid=@LMid and RV.RevStatus = PV.Pickid
ORDER BY RV.RevisionDate DESC

SELECT @ErrorCode = @@Error
END
SET NOCOUNT OFF
RETURN @ErrorCode
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-12 : 03:12:10
See my previous reply and apply that logic

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -