Skip to content

Hi how to set query while inserting to sql table for stored procedure for perticular column if register no reaches to 32 room no value should shange.

fahad sheikhji

fahad sheikhji

Asked Mar 17, 2012, 3:32 AM EDT1 answer
Share
LinkedInX
hi how to set stored procedure while inserting values to query like for example
RegisterNo,Semister and RoomNo these are columns
in one room no 32 register no s can save.if it reaches to 32 and we cant give same column name for that.?
can any one suggest me?and i want to display message in aspx that 101 room number exceeded 32 student so type other room number to save.?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    You need to check the value in the stored procedure before insert.

    When you have the required input then you can get the count.

    DECLARE @CheckCount INT

    SELECT  @CheckCount  = COUNT(RegisterNo) FROM RegistrationTable WHERE condition comes here...

    IF (@ CheckCount > 32)
    BEGIN
            RETURN 'Exceeded'
    END
    ELSE
    BEGIN
            INSERT INTO RegistrationTab...
            RETURN 'Success'
    END

    This is good way to approach... Other wise you can write separate stored procedure or query to check before call the SP.
    0