Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2.  
  3. MEMB_STAT: ORIGINAL DA MINHA DB
  4.  
  5. CREATE TABLE [dbo].[MEMB_STAT] (
  6. [memb___id] [varchar] (10) COLLATE Latin1_General_CS_AS NOT NULL ,
  7. [ConnectStat] [tinyint] NULL ,
  8. [ServerName] [varchar] (10) COLLATE Latin1_General_CI_AS NULL ,
  9. [IP] [varchar] (15) COLLATE Latin1_General_CI_AS NULL ,
  10. [ConnectTM] [smalldatetime] NULL ,
  11. [DisConnectTM] [smalldatetime] NULL ,
  12. [OnlineHours] [int] NOT NULL
  13. ) ON [PRIMARY]
  14. GO
  15.  
  16. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  17.  
  18. WZ_DISCONNECT_MEMB: ORIGINAL DA MINHA DB
  19.  
  20. CREATE PROCEDURE WZ_DISCONNECT_MEMB
  21. @memb___id varchar(10)
  22. AS
  23. Begin
  24. set nocount on
  25. Declare @find_id varchar(10)
  26. Declare @ConnectStat tinyint
  27. Set @ConnectStat = 0 -- Á¢¼Ó »óÅ °ª 1 = Á¢¼Ó, 0 = Á¢¼ÓX
  28. Set @find_id = 'NOT'
  29. select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
  30. where I.memb___id = @memb___id
  31.  
  32. if( @find_id <> 'NOT' ) -- Á¢¼Ó Á¾·á 󸮴 Á¢¼Ó 󸮸¦ ÇßÀ»¶§¸¸ À¯È¿ÇÏ°Ô ÇÑ´Ù
  33. begin
  34. update MEMB_STAT set ConnectStat = @ConnectStat, DisConnectTM = getdate()
  35. where memb___id = @memb___id
  36. end
  37. end
  38.  
  39. GO
  40. SET QUOTED_IDENTIFIER OFF
  41. GO
  42. SET ANSI_NULLS ON
  43. GO
  44.  
  45. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  46.  
  47. WZ_CONNECT_MEMB: Original da minha DB
  48.  
  49.  
  50. CREATE PROCEDURE WZ_CONNECT_MEMB
  51. @memb___id varchar(10),
  52. @ServerName varchar(20),
  53. @IP varchar(15)
  54. AS
  55. Begin
  56. set nocount on
  57. Declare @find_id varchar(10)
  58. Declare @ConnectStat tinyint
  59. Set @find_id = 'NOT'
  60. Set @ConnectStat = 1 -- Á¢¼Ó »óÅ °ª 1 = Á¢¼Ó, 0 = Á¢¼ÓX
  61.  
  62. select @find_id = S.memb___id from MEMB_STAT S INNER JOIN MEMB_INFO I ON S.memb___id = I.memb___id
  63. where I.memb___id = @memb___id
  64.  
  65. if( @find_id = 'NOT' )
  66. begin
  67. insert into MEMB_STAT (memb___id,ConnectStat,ServerName,IP,ConnectTM)
  68. values(@memb___id, @ConnectStat, @ServerName, @IP, getdate())
  69. end
  70. else
  71. update MEMB_STAT set ConnectStat = @ConnectStat,
  72. ServerName = @ServerName,IP = @IP,
  73. ConnectTM = getdate()
  74. where memb___id = @memb___id
  75. end
  76.  
  77. GO
  78. SET QUOTED_IDENTIFIER OFF
  79. GO
  80. SET ANSI_NULLS ON
  81. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement