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
 General SQL Server Forums
 New to SQL Server Programming
 Date exist

Author  Topic 

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-11 : 06:18:38
Hi, I have a table where a lot of items get logged, and I want to build a SP which checks for a certain month and year if it has items or not. Until now I have this, but it does not work yet:


ALTER procedure [dbo].[CheckIfLogExists]

@Month int,
@Year int,
@exists bit output

as

Set @exists = false

if exists(
select
LogID
From
LogTable
where
MONTH(LogDate) = @Month
AND
YEAR(LogDate) = @Year
)
set @exists=true

return @Exists


can anyone tell what I should do?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 06:24:19
quote:
Originally posted by trouble2

Hi, I have a table where a lot of items get logged, and I want to build a SP which checks for a certain month and year if it has items or not. Until now I have this, but it does not work yet:


ALTER procedure [dbo].[CheckIfLogExists]

@Month int,
@Year int,
@exists bit output

as

Set @exists = false

if exists(
select
LogID
From
LogTable
where
MONTH(LogDate) = @Month
AND
YEAR(LogDate) = @Year
)
set @exists=true 1

return @Exists


can anyone tell what I should do?

Go to Top of Page

trouble2
Constraint Violating Yak Guru

267 Posts

Posted - 2008-08-11 : 06:41:37
Thanks
Go to Top of Page
   

- Advertisement -