Transaction Log

  • Hi,

    I'm new to sql server and I'm looking for a command to fill up the transaction log of the adventureworks db so that I can work out how to resolve issues when this happens.

    Any help much appreciated.

    Thanks

  • Then why not run INSERT and DELETE statement in a loop?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Frank,

    Can you start me off with the syntax?

  • Maybe something like this will work:

    CREATE TABLE #t (c1 int);

    DECLARE @i int;

    SET @i = 1;

    WHILE @i <= 10 --adjust this

    BEGIN

    INSERT INTO #t SELECT @i;

    UPDATE #t SET c1 = @i;

    DELETE #t WHERE c1 = @i;

    SET @i = @i + 1;

    END

    SELECT * FROM #t;

    DROP TABLE #t;

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Oops, apparently you would want to repleace #t with a permanent table in the AdventureWorks database. 🙂

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks Frank, I'll give this a go.

  • Sorry before I do this, can I replace the #t with person.address?

  • you can. however, since the structure of person.address is different from what was shown in the example, you'll need to modify the queries for inserting.

    You can also create a permanent table, just remove the # from the sample table name.

    Alternatively, you may want to limit your transaction log to, say 1 MB without autogrowth and then run that example. your logs will get filled with much lesser number of loops.



    Pradeep Singh

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply