How can we help you today? How can we help you today?

Snippet for INSERT INTO CursorHere WITH TABLOCK

Hi,

I mentioned it in my diary study yesterday: Is it possible to create a snitppet for INSERT INTO CursorHere WITH TABLOCK ?

When defining INSERT INTO $CURSOR$ WITH TABLOCK it expands to:
INSERT INTO dbo.TableName
        (ColumnName)
VALUES    (0  -- ColumnName - smallint
         ) WITH (TABLOCK)

rather expanding to
INSERT INTO dbo.TableName WITH (TABLOCK) 
        (ColumnName)
VALUES    (0  -- ColumnName - smallint
         )

Since we want to use minimally logged inserts (trace flag 610 is on), we have to use WITH (TABLOCK) very often.
kondrich
0

Comments

6 comments

  • Aaron L
    I'll see what I can do about keeping the table hints with the table name :)
    Aaron L
    0
  • kondrich
    Thanks Aaron!
    kondrich
    0
  • Aaron L
    Hi Klaus,
    I've just updated our beta to 6.3.0.65 which should include this and a fix for the semicolon bug you reported. You can download it from the same URL as before.
    Aaron L
    0
  • kondrich
    Aaron,

    thanks for the new version. It's partially working: It seems that we have a semicolon issue here again.
    If the ii snippet is defined as
    INSERT INTO $CURSOR$ WITH (TABLOCK)
    
    it gets correctly expanded to
    INSERT INTO TableName WITH (TABLOCK)
    		(ColumnName)
    VALUES	(0  -- ColumnName- smallint
    		 )
    
    However, if the snippet is defined as
    INSERT INTO $CURSOR$ WITH (TABLOCK);
    
    (note the trailing semicolon) and I start typing ii+TAB: this leads to
    INSERT INTO | WITH (TABLOCK);
    
    (The pipe indicates the cursor position) So everything is fine until now. But after choosing a table name, the generated code gets replaced by:
    INSERT INTO TableName
    		(ColumnName)
    VALUES	(0  -- ColumnName- smallint
    		 )
    
    ...the table hint and the trailing semicolon are missing after full generation of the code.
    kondrich
    0
  • Aaron L
    Ok, one more try with 6.3.0.70 :) This build should keep the tablehint with the name and place the semicolon after the autogenerated code.
    Aaron L
    0
  • kondrich
    OK, 6.3.0.70 fixes that one. Thank you!
    kondrich
    0

Add comment

Please sign in to leave a comment.