日期:2014-05-18 浏览次数:20599 次
create table [LoginHistory] ( Id int identity(1,1) primary key, UserID int, LoginTime datetime, LogoutTime datetime, DeviceType int ) go create proc Add_LoginHistory ( @UserID int, @LoginTime datetime, @LogoutTime datetime, @DeviceType int ) as begin insert into [LoginHistory] ([UserID],[LoginTime],[LogoutTime],[DeviceType]) values (@UserID,@LoginTime,@LogoutTime,@DeviceType); select @@IDENTITY end go sp_executesql N'INSERT INTO [LoginHistory] ([UserID],[LoginTime],[LogoutTime],[DeviceType]) VALUES (@UserID,@LoginTime,@LogoutTime,@DeviceType);select @@IDENTITY', N'@UserID int,@LoginTime datetime,@LogoutTime datetime,@DeviceType int', @UserID=2, @LoginTime='2012-07-27 16:25:49.270', @LogoutTime=NULL, @DeviceType=1 exec Add_LoginHistory 2,'2012-07-27 16:25:49.270',null,1
------解决方案--------------------
sp_executesql N'INSERT INTO [LoginHistory] ([UserID],[LoginTime],[LogoutTime],[DeviceType]) VALUES (@UserID,@LoginTime,@LogoutTime,@DeviceType);select @@IDENTITY', N'@UserID int,@LoginTime datetime,@LogoutTime datetime,@DeviceType int', @UserID=2, @LoginTime='2012-07-27 16:25:49.270', @LogoutTime=NULL, @DeviceType=1 exec Add_LoginHistory 2,'2012-07-27 16:25:49.270',null,1 insert into [LoginHistory]([UserID],[LoginTime],[LogoutTime],[DeviceType]) values (2,'2012-07-27 16:25:49.270',null,1);
------解决方案--------------------