Loading ...
Sorry, an error occurred while loading the content.

need help about the primary key...

Expand Messages
  • Shyam Sunder
    Hi All, DECLARE @TNumber bigint SET @TNumber=cast(datepart(yyyy,Getdate())as varchar(4))+ cast(datepart(mm,Getdate()) as
    Message 1 of 4 , Dec 27, 2007
    • 0 Attachment
      Hi All,

      DECLARE @TNumber bigint
      SET @TNumber=cast(datepart(yyyy,Getdate())as varchar(4))+ cast(datepart(mm,Getdate()) as varchar(2))+cast(datepart(dd,Getdate()) as varchar(2))+ cast(datepart(hh,getdate()) as varchar(2))+cast(datepart(mi,getdate()) as varchar(2))+cast(datepart(ss,getdate()) as varchar(2))
      PRINT @TNumber

      Please let me know can i use the above value as primary key.

      instead of auto number can i perfer using the above value..

      Please suggest me...

      Best Regards
      Shyam Sunder .K
      Database Administrator.
      98851 33956.


      ____________________________________________________________________________________
      Never miss a thing. Make Yahoo your home page.
      http://www.yahoo.com/r/hs

      [Non-text portions of this message have been removed]
    • Santosh Samantaray
      Hi Shyam, yes it is possible as primary key but specify datatype of variable as numeric. with regards s.santosh ... -- With Regards S. Santosh [Non-text
      Message 2 of 4 , Dec 27, 2007
      • 0 Attachment
        Hi Shyam,
        yes it is possible as primary key but specify datatype of variable as
        numeric.

        with regards
        s.santosh


        On 12/27/07, Shyam Sunder <shyam_k25@...> wrote:
        >
        > Hi All,
        >
        > DECLARE @TNumber bigint
        > SET @TNumber=cast(datepart(yyyy,Getdate())as varchar(4))+
        > cast(datepart(mm,Getdate()) as varchar(2))+cast(datepart(dd,Getdate()) as
        > varchar(2))+ cast(datepart(hh,getdate()) as
        > varchar(2))+cast(datepart(mi,getdate()) as
        > varchar(2))+cast(datepart(ss,getdate()) as varchar(2))
        > PRINT @TNumber
        >
        > Please let me know can i use the above value as primary key.
        >
        > instead of auto number can i perfer using the above value..
        >
        > Please suggest me...
        >
        > Best Regards
        > Shyam Sunder .K
        > Database Administrator.
        > 98851 33956.
        >
        > __________________________________________________________
        > Never miss a thing. Make Yahoo your home page.
        > http://www.yahoo.com/r/hs
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >



        --
        With Regards
        S. Santosh


        [Non-text portions of this message have been removed]
      • Ramesh Karnati
        Yes, set the required column s default value as: CONVERT(VARCHAR, REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 120), , ), - , ), : , )) and
        Message 3 of 4 , Dec 27, 2007
        • 0 Attachment
          Yes, set the required column's default value as:

          CONVERT(VARCHAR, REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR, GETDATE(), 120), ' ', ''), '-', ''), ':', ''))

          and do not provide this value while inserting data in the table.

          Thanks,
          Karnati.

          Shyam Sunder <shyam_k25@...> wrote:
          Hi All,

          DECLARE @TNumber bigint
          SET @TNumber=cast(datepart(yyyy,Getdate())as varchar(4))+ cast(datepart(mm,Getdate()) as varchar(2))+cast(datepart(dd,Getdate()) as varchar(2))+ cast(datepart(hh,getdate()) as varchar(2))+cast(datepart(mi,getdate()) as varchar(2))+cast(datepart(ss,getdate()) as varchar(2))
          PRINT @TNumber

          Please let me know can i use the above value as primary key.

          instead of auto number can i perfer using the above value..

          Please suggest me...

          Best Regards
          Shyam Sunder .K
          Database Administrator.
          98851 33956.

          __________________________________________________________
          Never miss a thing. Make Yahoo your home page.
          http://www.yahoo.com/r/hs

          [Non-text portions of this message have been removed]






          ---------------------------------
          Never miss a thing. Make Yahoo your homepage.

          [Non-text portions of this message have been removed]
        • pankaj joshi
          Hello Shyam, Its not an good candidate for primary key as in multiuser scenario, it will not work if insert statement is fired concurrently . Regards Pankaj
          Message 4 of 4 , Dec 27, 2007
          • 0 Attachment
            Hello Shyam,

            Its not an good candidate for primary key as in multiuser scenario, it will not work if insert statement is fired concurrently .

            Regards
            Pankaj Joshi

            Shyam Sunder <shyam_k25@...> wrote:
            Hi All,

            DECLARE @TNumber bigint
            SET @TNumber=cast(datepart(yyyy,Getdate())as varchar(4))+ cast(datepart(mm,Getdate()) as varchar(2))+cast(datepart(dd,Getdate()) as varchar(2))+ cast(datepart(hh,getdate()) as varchar(2))+cast(datepart(mi,getdate()) as varchar(2))+cast(datepart(ss,getdate()) as varchar(2))
            PRINT @TNumber

            Please let me know can i use the above value as primary key.

            instead of auto number can i perfer using the above value..

            Please suggest me...

            Best Regards
            Shyam Sunder .K
            Database Administrator.
            98851 33956.

            __________________________________________________________
            Never miss a thing. Make Yahoo your home page.
            http://www.yahoo.com/r/hs

            [Non-text portions of this message have been removed]






            ---------------------------------
            5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.

            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.