Truncate table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sala

    #1

    Truncate table

    Hi
    I want to truncate all data in database ... pls help me how i ll
    truncate?

  • Sala

    #2
    Re: Truncate table


    Sala wrote:
    Hi
    I want to truncate all data in database ... pls help me how i ll
    truncate?
    Sala wrote:
    I am using sql server 2000..

    Comment

    • Bruce Wood

      #3
      Re: Truncate table


      Sala wrote:
      Hi
      I want to truncate all data in database ... pls help me how i ll truncate?
      Do you really mean "truncate"? Truncate typically means that you trim
      extra blank space from the ends of character strings. It doesn't sound
      like that is what you want to do.

      Do you mean "delete"? If so, you have to tell us whether you want to
      delete all rows in all tables (leaving the database table structure
      intact, but with no data), or you want to drop all tables from the
      database, leaving the database empty, without tables or data. The
      correct term for the first is "delete" (rows of data), while the
      correct term for the second is "drop" (tables).

      So... what is it you want to do?

      Comment

      • Rad [Visual C# MVP]

        #4
        Re: Truncate table

        On 15 Dec 2006 23:58:45 -0800, Sala wrote:
        Hi
        I want to truncate all data in database ... pls help me how i ll
        truncate?
        The truncate statement works as follows:

        truncate table TableName

        So all you need to do is run it for each of the tables in your database.
        You'd probably put this in a stored procedure to make it easier to run
        subsequently.

        However there are caveats -- you can't use it to on tables that are
        replicating, for instance

        --
        Bits.Bytes

        Comment

        • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

          #5
          Re: Truncate table

          Bruce Wood wrote:
          Sala wrote:
          > I want to truncate all data in database ... pls help me how i ll truncate?
          >
          Do you really mean "truncate"? Truncate typically means that you trim
          extra blank space from the ends of character strings. It doesn't sound
          like that is what you want to do.
          >
          Do you mean "delete"? If so, you have to tell us whether you want to
          delete all rows in all tables (leaving the database table structure
          intact, but with no data), or you want to drop all tables from the
          database, leaving the database empty, without tables or data. The
          correct term for the first is "delete" (rows of data), while the
          correct term for the second is "drop" (tables).
          >
          So... what is it you want to do?
          He probably want to do a TRUNCATE !

          http://msdn2.microsoft.com/en-us/library/ms177570.aspx

          Arne

          Comment

          • Carl Daniel [VC++ MVP]

            #6
            Re: Truncate table

            Rad [Visual C# MVP] wrote:
            On 15 Dec 2006 23:58:45 -0800, Sala wrote:
            >
            >Hi
            > I want to truncate all data in database ... pls help me how i ll
            >truncate?
            >
            The truncate statement works as follows:
            >
            truncate table TableName
            >
            So all you need to do is run it for each of the tables in your
            database. You'd probably put this in a stored procedure to make it
            easier to run subsequently.
            >
            However there are caveats -- you can't use it to on tables that are
            replicating, for instance
            Or on tables that are the target of foreign keys in other tables - even if
            those other tables are empty!

            -cd


            Comment

            • Bruce Wood

              #7
              Re: Truncate table


              Arne Vajhøj wrote:
              Bruce Wood wrote:
              Sala wrote:
              I want to truncate all data in database ... pls help me how i ll truncate?
              Do you really mean "truncate"? Truncate typically means that you trim
              extra blank space from the ends of character strings. It doesn't sound
              like that is what you want to do.

              Do you mean "delete"? If so, you have to tell us whether you want to
              delete all rows in all tables (leaving the database table structure
              intact, but with no data), or you want to drop all tables from the
              database, leaving the database empty, without tables or data. The
              correct term for the first is "delete" (rows of data), while the
              correct term for the second is "drop" (tables).

              So... what is it you want to do?
              >
              He probably want to do a TRUNCATE !
              >
              http://msdn2.microsoft.com/en-us/library/ms177570.aspx
              Ahhh! Shows how much I know, doesn't it? :-)

              Comment

              • Otis Mukinfus

                #8
                Re: Truncate table

                On 15 Dec 2006 23:58:45 -0800, "Sala" <salavudeen.a@g mail.comwrote:
                >Hi
                I want to truncate all data in database ... pls help me how i ll
                >truncate?
                Actually that is not a C# question.

                Why not try: microsoft.publi c.sqlserver.new users?

                Good luck with your project,

                Otis Mukinfus


                Comment

                • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

                  #9
                  Re: Truncate table

                  And the winner is.. Otis! This question had absolutely nothing to do with C#
                  language issues.
                  Peter

                  --
                  Co-founder, Eggheadcafe.com developer portal:

                  UnBlog:





                  "Otis Mukinfus" wrote:
                  On 15 Dec 2006 23:58:45 -0800, "Sala" <salavudeen.a@g mail.comwrote:
                  >
                  Hi
                  I want to truncate all data in database ... pls help me how i ll
                  truncate?
                  >
                  Actually that is not a C# question.
                  >
                  Why not try: microsoft.publi c.sqlserver.new users?
                  >
                  Good luck with your project,
                  >
                  Otis Mukinfus


                  >

                  Comment

                  • Otis Mukinfus

                    #10
                    Re: Truncate table

                    On Sat, 16 Dec 2006 17:22:00 -0800, Peter Bromberg [C# MVP]
                    <pbromberg@yaho o.nospammin.com wrote:
                    >And the winner is.. Otis! This question had absolutely nothing to do with C#
                    >language issues.
                    >Peter
                    Thanks, Peter!

                    Where do I go to collect the prize? ;o)

                    Good luck with your project,

                    Otis Mukinfus


                    Comment

                    • =?UTF-8?B?QXJuZSBWYWpow7hq?=

                      #11
                      Re: Truncate table

                      Peter Bromberg [C# MVP] wrote:
                      And the winner is.. Otis! This question had absolutely nothing to do with C#
                      language issues.
                      Correct.

                      But it is only obvious if you know that it should be done
                      via a SQL command and not directly in C#.

                      If people asking questions knew everything, then they would
                      not need to ask questions.

                      Arne


                      Comment

                      • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

                        #12
                        Re: Truncate table

                        Yes, and if everybody gave you exactly what you want 100% of the time, on a
                        silver platter, then you may never learn the protocol and netiquette, and
                        that would be too bad. Our job is not just to answer questions, but also to
                        help n00b posters become more professional so that they can better help
                        themselves.
                        Peter

                        --
                        Site: http://www.eggheadcafe.com
                        UnBlog: http://petesbloggerama.blogspot.com
                        Short urls & more: http://ittyurl.net




                        "Arne Vajhøj" wrote:
                        Peter Bromberg [C# MVP] wrote:
                        And the winner is.. Otis! This question had absolutely nothing to do with C#
                        language issues.
                        >
                        Correct.
                        >
                        But it is only obvious if you know that it should be done
                        via a SQL command and not directly in C#.
                        >
                        If people asking questions knew everything, then they would
                        not need to ask questions.
                        >
                        Arne
                        >
                        >
                        >

                        Comment

                        • =?UTF-8?B?QXJuZSBWYWpow7hq?=

                          #13
                          Re: Truncate table

                          Peter Bromberg [C# MVP] wrote:
                          Yes, and if everybody gave you exactly what you want 100% of the time, on a
                          silver platter, then you may never learn the protocol and netiquette, and
                          that would be too bad. Our job is not just to answer questions, but also to
                          help n00b posters become more professional so that they can better help
                          themselves.
                          And do you think the original poster learned anything from
                          your post ?

                          Not counting that he learned that some people in this group
                          are arrogant and rude !

                          Arne

                          Comment

                          • Otis Mukinfus

                            #14
                            Re: Truncate table

                            On Sun, 24 Dec 2006 23:20:30 -0500, Arne Vajhøj <arne@vajhoej.d kwrote:
                            >Peter Bromberg [C# MVP] wrote:
                            >Yes, and if everybody gave you exactly what you want 100% of the time, on a
                            >silver platter, then you may never learn the protocol and netiquette, and
                            >that would be too bad. Our job is not just to answer questions, but also to
                            >help n00b posters become more professional so that they can better help
                            >themselves.
                            >
                            >And do you think the original poster learned anything from
                            >your post ?
                            >
                            >Not counting that he learned that some people in this group
                            >are arrogant and rude !
                            >
                            >Arne
                            Actually, when I posted the answer I made no arrogant remarks. I simply stated
                            that it was a question for the SQL Server group and gave the news group address.

                            Are you saying that the OP learned nothing from my answer?

                            I did not admonish the user, nor did I imply that I know more about civility or
                            SQL Server than the OP. Since I did give the OP the news group address I
                            suspect they learned that there was a group specifically for SQL Server
                            questions. Since there were no more questions posted by the OP I presume they
                            took the next logical step and consulted the SQL Server group I suggested.

                            On the other hand, your post does nothing to assist in the learning process. It
                            only admonishes Peter and I for what you perceived as bad behavior. I suggest
                            you take a look in the mirror and see who the arrogant party might be.

                            Good luck with your project,

                            Otis Mukinfus


                            Comment

                            • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

                              #15
                              Re: Truncate table

                              Otis Mukinfus wrote:
                              On Sun, 24 Dec 2006 23:20:30 -0500, Arne Vajhøj <arne@vajhoej.d kwrote:
                              >Peter Bromberg [C# MVP] wrote:
                              >>Yes, and if everybody gave you exactly what you want 100% of the time, on a
                              >>silver platter, then you may never learn the protocol and netiquette, and
                              >>that would be too bad. Our job is not just to answer questions, but also to
                              >>help n00b posters become more professional so that they can better help
                              >>themselves.
                              >And do you think the original poster learned anything from
                              >your post ?
                              >>
                              >Not counting that he learned that some people in this group
                              >are arrogant and rude !
                              Actually, when I posted the answer I made no arrogant remarks. I simply stated
                              that it was a question for the SQL Server group and gave the news group address.
                              >
                              Are you saying that the OP learned nothing from my answer?
                              I did not say that.

                              Hint: when I quote someone and make a comment then my comment is
                              related to that and not to a previous non quoted post.

                              But regarding you post then:
                              - you did not explain why you think that the suggested newsgroup
                              was better
                              - it is a definite possibility that the suggestion was completely wrong
                              (TRUNCATE TABLE is a valid TSQL command - and if the poster knew that
                              then your suggestion is way off - but there are also the possibility
                              that the subject was chosen as plain english not TSQL in which case
                              your suggestion was a good one)

                              I did not find any reason to comment on that.
                              On the other hand, your post does nothing to assist in the learning process. It
                              only admonishes Peter and I for what you perceived as bad behavior. I suggest
                              you take a look in the mirror and see who the arrogant party might be.
                              My post did not have any benefit for the original poster.

                              But if it did make some of the more knowledgeable remember, that
                              once upon a time they where asking the wrong questions in the wrong
                              forums too, then it may help future posters.

                              Arne

                              Comment

                              Working...