Click to See Complete Forum and Search --> : return bit value


sukahati
03-29-2007, 09:33 PM
i have problem to return bit value. i have a stored procedure where it check the bit value wether it is 0 or 1 and do some query depends on the condition. it works fine if im not using dynamic db, but the problem is i have to change it to dynamic. it did not pass the value to itself. below is the sp if it is not dynamic

CREATE PROCEDURE [dbo].[SP_AccHolderDefaultView]
(
@CompID NVarChar(13),
@CheckCust bit OUTPUT
)

AS

BEGIN
SET NOCOUNT ON;

SELECT @CheckCust = d.is_Cust
FROM T_RefTable.DBO.Traders As d (NOLOCK)
INNER JOIN T_ceFinance.DBO.CustAcct As a (NOLOCK) ON a.code= d.trader --change by suyee
INNER JOIN Company As p(NOLOCK)ON p.CompanyCode=a.code
WHERE p.NewCompanyID=@CompID

IF @CheckCust= 1
Select d.name from T_RefTable.dbo.Traders as d inner join Company As p (NOLOCK) on p.CompanyCode=d.trader WHERE p.NewCompanyID='+''''+@CompID+''''+' AND p.IsDeleted=0

END

anybody can help on it?

russell
03-30-2007, 01:49 PM
remove the semi-colon after set nocount on

sukahati
04-01-2007, 10:03 PM
remove the semi-colon does not answered my question. But nway thanks. ok...i got idea to create a temp table but still cannot work. anyone?

mattyblah
04-04-2007, 02:56 PM
Having a hard time trying to understand you. Are you saying that the output variable @CheckCust is not getting set? What is the value getting set to? AFAIK the value should be set to either 1, 0 or null perhaps if a value is not found in the database. What is the value of @CheckCust getting set to? What do you mean by dynamic db? Anyways, hope that helps.