create proc [dbo].[ymd] @str varchar(50) output
AS
declare @y varchar(10),
@m varchar(10),
@d varchar(10),
@e datetime,
@cont int
begin
set @e=getdate()
set @y=str(year(@e))
set @m=str(month(@e))
set @d=str(day(@e))
if len(ltrim(rtrim(@m)))<2
begin
set @m='0'+ltrim(rtrim(@m))
end
if len(ltrim(rtrim(@d)))<2
begin
set @d='0'+ltrim(rtrim(@d))
end
set @str=ltrim(rtrim(@y))+ltrim(rtrim(@m))+ltrim(rtrim(@d))
select Batch_id into tmptable1 from ProductBatchTab where left(Batch_id,8)=@str
set @cont=(select count(Batch_id) as coun1 from tmptable1)+1
if len(@cont)<2
begin
set @str=ltrim(rtrim(str(@str)))+'0'+ltrim(rtrim(str(@cont)))
end
else
set @str=ltrim(rtrim(str(@str)))+ltrim(rtrim(str(@cont)))
select @str
drop table tmptable1
end
我的存储过程是这样的
我不知道如何调用!
create proc aa
as
declare @cc
set @cc=year(getdate())+month(getdate())+day(getdate())+怎么个自动生成
select @cc
public string Getresult()
{
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("aa", myConnection);