.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

how to solve error in the storeprocedure

Posted By: parthiban     Posted Date: April 18, 2013    Points:5   Category :Sql Server
wrote a storedprocedure for restricting no of users registrations daily to 10..

found error while executing..


use employee
go


create proc joinmax
@name varchar(50),@email varchar(50),@phoneno varchar(50),@regdate datetime,@ERROR VARCHAR(100) OUT


as

begin
SET NOCOUNT ON;
(select count(id) from joinees
where year(regdate) = year(getdate())
and month(regdate) = month(getdate())
and day(regdate) = day(getdate())
)
if(count(id)>10



INSERT INTO joinees(name,email,phoneno) values(@name,@email,@phoneno)

SET @ERROR=@name+' Registered Successfully'
END
ELSE
BEGIN


--If User already Exists i am returning this Message as Output Parameter
SET @ERROR=@name + ' max limit reached'
END


Responses
Author: Deco             
Posted Date: April 19, 2013     Points: 20   

Parthiban,

Please use this stored procedure


create proc joinmax
(
@name varchar(50)
,@email varchar(50)
,@phoneno varchar(50)
,@regdate datetime
,@ERROR VARCHAR(100) OUT
)
as
begin
SET NOCOUNT ON;
DECLARE @Count INTEGER

select @Count = count(id)
from joinees
where year(regdate) = year(getdate())
and month(regdate) = month(getdate())
and day(regdate) = day(getdate())

if(@Count >= 10)
BEGIN
INSERT INTO joinees(name,email,phoneno)
VALUES(@name,@email,@phoneno)

SET @ERROR=@name+' Registered Successfully'
END
ELSE
BEGIN
--If User already Exists i am returning this Message as Output Parameter
SET @ERROR=@name + ' max limit reached'
END
END


Regards,
Deco
Author: ashleyturnier             
Posted Date: October 11, 2013     Points: 20   

Sorry i don't know the answer.anybody know?



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend