Verification using stored procedure

I have tried verification using stored procedure in SQL Server. But the stored procedure is not working.

I have a table room. I got the backup from room table as a room backup. I tried to verify in SQL Server using stored procedure, when room table record greater than room back up table record, so I need to rewrite the room backup table. I tried the following code but it's not working

CREATE PROC Sp_verify
AS
    IF (SELECT Count()
        FROM   Room) > (SELECT Count()
                        FROM   RoomBackup)
      BEGIN
          DELETE RoomBackup;

          INSERT INTO RoomBackup
                      (R_No,
                       R_Type,
                       R_stus,
                       AP_No,
                       P_Name,
                       R_Charge)
          SELECT R_No,
                 R_Type,
                 R_stus,
                 AP_No,
                 P_Name,
                 R_Charge
          FROM   Room;
      END 

Please help me

Answers


Modify procedure as given below:

IF ((SELECT Count(1)
        FROM   Room) > (SELECT Count(1)
                        FROM   RoomBackup))
      BEGIN
          DELETE RoomBackup;

          INSERT INTO RoomBackup
                      (R_No,
                       R_Type,
                       R_stus,
                       AP_No,
                       P_Name,
                       R_Charge)
          SELECT R_No,
                 R_Type,
                 R_stus,
                 AP_No,
                 P_Name,
                 R_Charge
          FROM   Room;
      END 

Count function requires an argument. Also enclosing brackets were required for if clause


Need Your Help

how do I get Mixer channels layout in java

java audio javasound mixer channels

I thought I can find anything on this great site but now I seem to face the issue with no answer :) Please help!

Can't request facebook's user_birthday

facebook api

I received permission from facebook api to request user's birthday. So it's like everything is fine and in developers.facebook.com I can see, that user_birthday is live. Everything is fine till I r...