Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Read LFD(log ) file SQLserver 2008

Read LFD(log ) file SQLserver 2008

Scheduled Pinned Locked Moved Database
databasecsharphelpquestion
24 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jojoba2011

    thanks for solution. but it wont give me that when and what for example insert/Delete/Update/Select in/from tblName. I wanna something log like this.

    M Offline
    M Offline
    Mycroft Holmes
    wrote on last edited by
    #6

    To do this you need to implement an AUDITING strategy, this generally involves triggers (spit) and an audit table. Do some research on database Auditing.

    Never underestimate the power of human stupidity RAH

    L 1 Reply Last reply
    0
    • J jojoba2011

      thanks for solution. but it wont give me that when and what for example insert/Delete/Update/Select in/from tblName. I wanna something log like this.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #7

      jojoba2011 wrote:

      but it wont give me that when and what for example

      When, what, and even who are included.

      Bastard Programmer from Hell :suss:

      J 1 Reply Last reply
      0
      • M Mycroft Holmes

        To do this you need to implement an AUDITING strategy, this generally involves triggers (spit) and an audit table. Do some research on database Auditing.

        Never underestimate the power of human stupidity RAH

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #8

        Mycroft Holmes wrote:

        this generally involves triggers

        Cool suggestion :cool:

        Bastard Programmer from Hell :suss:

        1 Reply Last reply
        0
        • L Lost User

          jojoba2011 wrote:

          but it wont give me that when and what for example

          When, what, and even who are included.

          Bastard Programmer from Hell :suss:

          J Offline
          J Offline
          jojoba2011
          wrote on last edited by
          #9

          Really thanks for all your Solutions! but i have sqlexpress and this feature isnot active in Express 2008! What can i do then?

          L 1 Reply Last reply
          0
          • J jojoba2011

            Really thanks for all your Solutions! but i have sqlexpress and this feature isnot active in Express 2008! What can i do then?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #10

            Creating a trace is also possible for Sql Express. Google Harder :)

            Bastard Programmer from Hell :suss:

            J 1 Reply Last reply
            0
            • L Lost User

              Creating a trace is also possible for Sql Express. Google Harder :)

              Bastard Programmer from Hell :suss:

              J Offline
              J Offline
              jojoba2011
              wrote on last edited by
              #11

              Hi, but trace can only catch the Error not the work i wanna.

              J L 2 Replies Last reply
              0
              • J jojoba2011

                Hi, but trace can only catch the Error not the work i wanna.

                J Offline
                J Offline
                JohnPayton
                wrote on last edited by
                #12

                You can't always expect a solution to your problem to be handed to you. Google is one of the best resources for finding answers to programming questions. If you don't get the answer you are looking for, restructure your Google key words until you get an answer that will work for you. Basically it's the best way to learn anyway, by doing it yourself.

                1 Reply Last reply
                0
                • J jojoba2011

                  Hi, but trace can only catch the Error not the work i wanna.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #13

                  You're right. A trace logs all actions. I'm not sure why you keep insisting that it won't work.

                  Bastard Programmer from Hell :suss:

                  J 1 Reply Last reply
                  0
                  • L Lost User

                    You're right. A trace logs all actions. I'm not sure why you keep insisting that it won't work.

                    Bastard Programmer from Hell :suss:

                    J Offline
                    J Offline
                    jojoba2011
                    wrote on last edited by
                    #14

                    thanks for Solution! is it posssible for you to give me small Example on how to use trace for all action.

                    L 1 Reply Last reply
                    0
                    • J jojoba2011

                      thanks for Solution! is it posssible for you to give me small Example on how to use trace for all action.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #15

                      There are quite some examples on the internet; some are based on Sql-statements, others on SMO. It's your turn to do some research :)

                      Bastard Programmer from Hell :suss:

                      J 1 Reply Last reply
                      0
                      • L Lost User

                        There are quite some examples on the internet; some are based on Sql-statements, others on SMO. It's your turn to do some research :)

                        Bastard Programmer from Hell :suss:

                        J Offline
                        J Offline
                        jojoba2011
                        wrote on last edited by
                        #16

                        I know that i should do the rest of work but i am little week in Googling.I didnt find any result that can give me the way.plz give me the link or Exmaple. Plz thanks

                        L 1 Reply Last reply
                        0
                        • J jojoba2011

                          I know that i should do the rest of work but i am little week in Googling.I didnt find any result that can give me the way.plz give me the link or Exmaple. Plz thanks

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #17

                          Two options; Using code[^], and using SQL[^].

                          Bastard Programmer from Hell :suss:

                          J 1 Reply Last reply
                          0
                          • L Lost User

                            Two options; Using code[^], and using SQL[^].

                            Bastard Programmer from Hell :suss:

                            J Offline
                            J Offline
                            jojoba2011
                            wrote on last edited by
                            #18

                            Thanks for reply! I have create App. and trace everything in SQL but I cannot trace SP and ... that will call from C#. I mean when i call SP in C# it doesnt trace. //را یکبار اجرا نمایید SP این trace ابتدا باید برای فعال کردن declare @TraceId int -- create the trace exec sp_trace_create @TraceId output, 0, N'C:\Temp\OurDemoTrace' -- set event and columns to trace exec sp_trace_setevent @TraceId, 12, 1, 1 exec sp_trace_setevent @TraceId, 12, 6, 1 exec sp_trace_setevent @TraceId, 13, 1, 1 exec sp_trace_setevent @TraceId, 13, 6, 1 -- start the trace exec sp_trace_setstatus @TraceId, 1 -- check status for our trace select value from fn_trace_getinfo(@TraceId) where property in (2, 5) go

                            sb.AppendLine("\nEventClass: " + ts.GetString(ts.GetOrdinal("EventClass")));
                            sb.AppendLine("NTUserName: " + ts.GetString(ts.GetOrdinal("NTUserName")));
                            sb.AppendLine("Command : " + ts.GetString(ts.GetOrdinal("TextData")));

                            L 1 Reply Last reply
                            0
                            • J jojoba2011

                              Thanks for reply! I have create App. and trace everything in SQL but I cannot trace SP and ... that will call from C#. I mean when i call SP in C# it doesnt trace. //را یکبار اجرا نمایید SP این trace ابتدا باید برای فعال کردن declare @TraceId int -- create the trace exec sp_trace_create @TraceId output, 0, N'C:\Temp\OurDemoTrace' -- set event and columns to trace exec sp_trace_setevent @TraceId, 12, 1, 1 exec sp_trace_setevent @TraceId, 12, 6, 1 exec sp_trace_setevent @TraceId, 13, 1, 1 exec sp_trace_setevent @TraceId, 13, 6, 1 -- start the trace exec sp_trace_setstatus @TraceId, 1 -- check status for our trace select value from fn_trace_getinfo(@TraceId) where property in (2, 5) go

                              sb.AppendLine("\nEventClass: " + ts.GetString(ts.GetOrdinal("EventClass")));
                              sb.AppendLine("NTUserName: " + ts.GetString(ts.GetOrdinal("NTUserName")));
                              sb.AppendLine("Command : " + ts.GetString(ts.GetOrdinal("TextData")));

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #19

                              jojoba2011 wrote:

                              and trace everything in SQL but I cannot trace SP and ... that will call from C#.
                              I mean when i call SP in C# it doesnt trace.

                              Not quite everything; stored procedures have their own trave_event, specifically SP:StmtStarting (44) and SP:StmtCompleted (45). A complete list of events can be found here[^].

                              Bastard Programmer from Hell :suss:

                              J 2 Replies Last reply
                              0
                              • L Lost User

                                jojoba2011 wrote:

                                and trace everything in SQL but I cannot trace SP and ... that will call from C#.
                                I mean when i call SP in C# it doesnt trace.

                                Not quite everything; stored procedures have their own trave_event, specifically SP:StmtStarting (44) and SP:StmtCompleted (45). A complete list of events can be found here[^].

                                Bastard Programmer from Hell :suss:

                                J Offline
                                J Offline
                                jojoba2011
                                wrote on last edited by
                                #20

                                thanks a lot Eddy Vluggen. Your really an export in SQL. I have use this for SP:

                                declare @TraceId int
                                -- create the trace
                                exec sp_trace_create @TraceId output, 0, N'C:\Temp\SQLLog'
                                -- set event and columns to trace
                                exec sp_trace_setevent @TraceId, 12, 1, 1
                                exec sp_trace_setevent @TraceId, 12, 6, 1
                                exec sp_trace_setevent @TraceId, 13, 1, 1
                                exec sp_trace_setevent @TraceId, 13, 6, 1
                                exec sp_trace_setevent @TraceId, 12, 13, 1
                                exec sp_trace_setevent @TraceId, 12, 10, 1
                                exec sp_trace_setevent @TraceId, 12, 13, 1
                                exec sp_trace_setevent @TraceId, 12, 14, 1
                                exec sp_trace_setevent @TraceId, 12, 15, 1
                                exec sp_trace_setevent @TraceId, 13, 10, 1
                                exec sp_trace_setevent @TraceId, 13, 13, 1
                                exec sp_trace_setevent @TraceId, 13, 14, 1
                                exec sp_trace_setevent @TraceId, 13, 15, 1
                                exec sp_trace_setevent @TraceId, 12, 35, 1
                                exec sp_trace_setevent @TraceId, 13, 35, 1
                                exec sp_trace_setevent @TraceId, 44, 10, 1
                                exec sp_trace_setevent @TraceId, 44, 13, 1
                                exec sp_trace_setevent @TraceId, 44, 14, 1
                                exec sp_trace_setevent @TraceId, 44, 15, 1
                                exec sp_trace_setevent @TraceId, 44, 1, 1
                                exec sp_trace_setevent @TraceId, 44, 6, 1
                                exec sp_trace_setevent @TraceId, 44, 35, 1
                                exec sp_trace_setevent @TraceId, 45, 35, 1
                                exec sp_trace_setevent @TraceId, 45, 10, 1
                                exec sp_trace_setevent @TraceId, 45, 13, 1
                                exec sp_trace_setevent @TraceId, 45, 14, 1
                                exec sp_trace_setevent @TraceId, 45, 15, 1
                                exec sp_trace_setevent @TraceId, 45, 1, 1
                                exec sp_trace_setevent @TraceId, 45, 6, 1

                                        -- start the trace
                                        exec sp\_trace\_setstatus @TraceId, 1
                                        -- check status for our trace
                                        select value from fn\_trace\_getinfo(@TraceId) where property in (2, 5)
                                        go
                                

                                and in C#

                                sb = new StringBuilder();
                                sb.AppendLine("\nEventClass: " + ts.GetString(ts.GetOrdinal("EventClass")));
                                sb.AppendLine("NTUserName: " + ts.GetString(ts.GetOrdinal("NTUserName")));
                                sb.AppendLine("Command : " + ts.GetString(ts.GetOrdinal("TextData")));

                                1 Reply Last reply
                                0
                                • L Lost User

                                  jojoba2011 wrote:

                                  and trace everything in SQL but I cannot trace SP and ... that will call from C#.
                                  I mean when i call SP in C# it doesnt trace.

                                  Not quite everything; stored procedures have their own trave_event, specifically SP:StmtStarting (44) and SP:StmtCompleted (45). A complete list of events can be found here[^].

                                  Bastard Programmer from Hell :suss:

                                  J Offline
                                  J Offline
                                  jojoba2011
                                  wrote on last edited by
                                  #21

                                  No ans for my Question!

                                  L 1 Reply Last reply
                                  0
                                  • J jojoba2011

                                    No ans for my Question!

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #22

                                    jojoba2011 wrote:

                                    No ans for my Question

                                    You do realize that we're volunteers here? I know that Sql-profiler can see the parameters, I assume that they're also there for a trace. I don't have an answer ready for this question.

                                    Bastard Programmer from Hell :suss:

                                    J 1 Reply Last reply
                                    0
                                    • L Lost User

                                      jojoba2011 wrote:

                                      No ans for my Question

                                      You do realize that we're volunteers here? I know that Sql-profiler can see the parameters, I assume that they're also there for a trace. I don't have an answer ready for this question.

                                      Bastard Programmer from Hell :suss:

                                      J Offline
                                      J Offline
                                      JohnPayton
                                      wrote on last edited by
                                      #23

                                      Here have a 5 for patience and being...

                                      really an export in SQL

                                      ;)

                                      L 1 Reply Last reply
                                      0
                                      • J JohnPayton

                                        Here have a 5 for patience and being...

                                        really an export in SQL

                                        ;)

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #24

                                        Thanks for exporting me :cool:

                                        1 Reply Last reply
                                        0
                                        Reply
                                        • Reply as topic
                                        Log in to reply
                                        • Oldest to Newest
                                        • Newest to Oldest
                                        • Most Votes


                                        • Login

                                        • Don't have an account? Register

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • World
                                        • Users
                                        • Groups