大概是这样写的
select isnull(max(SID)+1,cast(year(getdate()) as char(4))+'0001')
//true时返回最大值加1,false里返回转为char类型的当前年份再加0001
from studentinfo
where cast(max(SID) as varchar(4))=cast(year(getdate())
//当年份等于最在值年份时
但是我不知道怎么把这个结果到加存储过程的参数中去
USE [Student]
GO
CREATE PROCEDURE [insert_SInfo_proc]
(@SID
[char](8),
@SName
[varchar](50),
@SCity
[varchar](50),
@SCounty
[varchar](50),
@SInTime
[datetime],
@SBirtyDay
[datetime],
@SEmail
[varchar](20),
@SSex
[char](2),
@SSkill
[char](10),
@SRemarks
[varchar](100))
AS INSERT INTO [Student].[dbo].[SInfo]
( [SID],
[SName],
[SCity],
[SCounty],
[SInTime],
[SBirtyDay],
[SEmail],
[SSex],
[SSkill],
[SRemarks])
VALUES
( @SID,
@SName,
@SCity,
@SCounty,
@SInTime,
@SBirtyDay,
@SEmail,
@SSex,
@SSkill,
@SRemarks)
麻烦你再帮我看看