|
Select top 100 State, JoinState,
(Case
When State = 1 and Joinstate = 0 then 2
When State = 1 and JoinState = 1 then 1
Else 0
End)
As usestate
From UserInfo
(Generate the maximum sequential number of the day)
Select substring (convert (varchar (8), getdate (), 112), 1, 8)
+ '123'
+ Replicate ('0', 4-len (max_ContractNo) -- repeat character expressions by specified number of times
+ Cast (max_ContractNo as varchar (4 ))
From (select
Case
When substring (max (My_ContractNo), 12, 4) is null then '1'
Else cast (substring (max (My_ContractNo), 12, 4) as bigint) + 1 as varchar (8 ))
End max_ContractNo
From UserContractNo
WHERE datediff (Day, Adddate, getdate () = 0
) S
Create table [UserContractNo] (
[Id] [int] IDENTITY (1, 1) not null,
[ApplyUserDetailID] [int] not null,
[My_ContractNo] [varchar] (50) COLLATE Chinese_PRC_CI_AS not null constraint [DF_UserContractNo_My_ContractNo] DEFAULT (''),
[AddDate] [datetime] not null constraint [DF_UserContractNo_AddDate] DEFAULT (getdate ()),
[Remarks] [varchar] (50) COLLATE Chinese_PRC_CI_AS not null constraint [DF_UserContractNo_Remarks] DEFAULT (''),
CONSTRAINT [PK_UserContractNo] PRIMARY KEY CLUSTERED
([Id] ASC) ON [PRIMARY]
) ON [PRIMARY] |