none
Membuat Auto Number RRS feed

  • Pertanyaan

  • Halo semua mohon bantuannya,

    bagaimana caranya untuk membuat nomor seperti contoh berikut :

    Inv/2011/001 atau inv/0001

    kalo di mysql saya biasa select seperti ini : SELECT COUNT(*) AS Expr2, NoJurnal AS Expr1 FROM Jurnal_Copy GROUP BY tgl Asc

    tapi kalau di sql server tidak bisa, di edit seperti apa ya biar bisa atau ada cara lain ?

    Mohon bantuannya

     

    Thans

     

     

     

    Jumat, 04 Februari 2011 07.37

Jawaban

  • Halo Nikelodeon,

    Dalam case ini, anda sebaiknya menggunakan Order by

    Sebagai contoh, SELECT COUNT(*) AS Expr2, NoJurnal AS Expr1 FROM Jurnal_Copy GROUP BY tgl order by tgl Asc

     

    Semoga membantu.

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Selasa, 08 Februari 2011 06.02
    Moderator
  • Halo Nikelodeon,

    Dalam case ini, anda sebaiknya menggunakan Order by

    Sebagai contoh, SELECT COUNT(*) AS Expr2, NoJurnal AS Expr1 FROM Jurnal_Copy GROUP BY tgl order by tgl Asc

     

    Semoga membantu.

     

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Terima kasih atas bantuanyya. setelah saya otak atik akhirnya berhasil juga. Berikut codenya siapa tau ada yang perlu
    Private Function ReferNo() As String
            Using conn As New SqlConnection(ConnDB.CONN_STRING)
               
                Using cmd As SqlCommand = New SqlCommand("SELECT TOP (1) substring((no_jurnal),5,7) as no_jurnal from t_jurnal Order By no Desc", conn)
                    conn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
                        If dr.Read = False Then
                            txtNoTransaksi.Text = "JKM-0000001"
                        Else
                            txtNoTransaksi.Text = "JKM-" & Format(Val(CInt(Microsoft.VisualBasic.Right(dr.Item("no_jurnal"), _
                                     dr.Item("no_jurnal").Length - 1)) + 1), "0000000")
                        End If
                        Return txtNoTransaksi.Text
                    End Using
                End Using
            End Using
        End Function

    Rabu, 16 Februari 2011 08.15

Semua Balasan

  • Halo Nikelodeon,

    Dalam case ini, anda sebaiknya menggunakan Order by

    Sebagai contoh, SELECT COUNT(*) AS Expr2, NoJurnal AS Expr1 FROM Jurnal_Copy GROUP BY tgl order by tgl Asc

     

    Semoga membantu.

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Selasa, 08 Februari 2011 06.02
    Moderator
  • Halo Nikelodeon,

    Dalam case ini, anda sebaiknya menggunakan Order by

    Sebagai contoh, SELECT COUNT(*) AS Expr2, NoJurnal AS Expr1 FROM Jurnal_Copy GROUP BY tgl order by tgl Asc

     

    Semoga membantu.

     

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Terima kasih atas bantuanyya. setelah saya otak atik akhirnya berhasil juga. Berikut codenya siapa tau ada yang perlu
    Private Function ReferNo() As String
            Using conn As New SqlConnection(ConnDB.CONN_STRING)
               
                Using cmd As SqlCommand = New SqlCommand("SELECT TOP (1) substring((no_jurnal),5,7) as no_jurnal from t_jurnal Order By no Desc", conn)
                    conn.Open()
                    Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
                        If dr.Read = False Then
                            txtNoTransaksi.Text = "JKM-0000001"
                        Else
                            txtNoTransaksi.Text = "JKM-" & Format(Val(CInt(Microsoft.VisualBasic.Right(dr.Item("no_jurnal"), _
                                     dr.Item("no_jurnal").Length - 1)) + 1), "0000000")
                        End If
                        Return txtNoTransaksi.Text
                    End Using
                End Using
            End Using
        End Function

    Rabu, 16 Februari 2011 08.15
  • Halo Nikelodeon,

    Senang bisa membantu dan terima kasih anda berbaik hati memposting code anda di forum ini. Dengan ini lebih banyak lagi community member yang akan terbantu bila mengalami casa yang sama dengan anda.

     


    Agnes Sannie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Rabu, 16 Februari 2011 09.15
    Moderator