我的存储过程是想输出yymmdd+自动生成的编号,还要把他输出是页面上, 不知道该怎么解决,高手帮忙一下!!!

解决方案 »

  1.   

    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); myCommand.CommandType = CommandType.StoredProcedure;
    myConnection.Open();
    try
    {
    string result=(string)myCommand.ExecuteScalar();
    myConnection.Close();
    return result;
    }
    catch(SqlException ee)
    {
    string e=ee.Message;
    myConnection.Close();
    return "";
    }
    }
      

  2.   

    select (convert(varchar,getdate(),12) + convert(varchar(50),newid())) AS id
      

  3.   

    create proc aa
    as
    declare @cc
    set @cc=year(getdate())+month(getdate())+day(getdate())+怎么个自动生成
    select @cc没有指定类型
      

  4.   

    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
    我的存储过程是这样的 
     我不知道如何调用!
      

  5.   

    create proc x
    as
    return select year(getdate())+month(getdate())+day(getdate())+rand()
      

  6.   

    我的存储过程是想输出yymmdd+自动生成自增的编号! 还有是怎么把他调用的?
      

  7.   

    楼上的请问一下
    +rand()是什么意思 只要前边的不行吗?
      

  8.   

    jijl2001(jijl2001)的方法,
     加上几句:
    string str; 
    SqlParameter myParameter = new SqlParameter("@str", str);
    myParameter.Direction = ParameterDirection.Output;
      

  9.   

    还少了myCommand.parameters.Add(myParameter);
      

  10.   

    declare @mydate char(6)
    set @mydate=CONVERT(char(6) , getdate(), 12 )
    select @mydate
    ----result-----
    051103
    ----result-----
      

  11.   

    要加编号,如果要求编号接着上一条记录的话 就得:
    declare @mydate varchar(12)
    set @mydate=CONVERT(char(6) , getdate(), 12 ) //@mydate = 051103
    declare @prebianhao char(12)
    select @prebianhao=bianhao from tablename where bianhao =上一条记录//取得上一条记录编号,假设为05110301
    declare @bianhao varchar(8)
    set @bianhao=substring(@prebianhao,5,len(@prebianhao ))//取得上一条记录编号的最后几位,@bianhao=01
    set @bianhao =  convert(int,@bianhao)+1 //@bianhao=01
    select @mydate + convert(char(6),@bianhao)+//得到新的05110302--------实验SQL---------
    declare @mydate varchar(12)
    set @mydate=CONVERT(char(6) , getdate(), 12 )
    select @mydate
    declare @bianhao varchar(8)
    set @bianhao=substring(@mydate,5,len(@mydate))
    set @bianhao =  convert(int,@bianhao)+1
    select @bianhao
    select @mydate+convert(varchar(6),@bianhao)
      

  12.   

    vovo2000(没人要的猫) 
    我的意思就是把年月日取过来 ,后面+一个自动生成的编号,那怎么把这个编号显示在前台