Loading ...
Sorry, an error occurred while loading the content.

Re: [mugh-sqlcon] help required

Expand Messages
  • Roji. P. Thomas
    Avik, I guess you are trying to execute the blow statements from Query Analyser. OUTPUT clause is a feature of SQL Server 2005 and you can test it using SQL
    Message 1 of 2 , Jul 27, 2005
    • 0 Attachment
      Avik,
       
      I guess you are trying to execute the blow statements from Query Analyser.
       
      OUTPUT clause is a feature of SQL Server 2005 and you can test it using
      SQL server Management Studio, the all-in-one client tool for SQL server 2005.
       
       
      Regards
      Roji. P. Thomas
      NetAssetManagement
      ----- Original Message -----
      Sent: Wednesday, July 27, 2005 2:05 PM
      Subject: [mugh-sqlcon] help required

      Hi all,

      This is a simple query which I use 2 utilize the output clause with DELETE

      Which is doing a simple thing:

      a CREATE TABLE statement creates the OutputTest table and then a series of INSERT commands populate it with sample data. Next, a DECLARE command creates the @DeletedTable TABLE variable that will be populated as a result of the OUTPUT clause associated with the DELETE OutputTest command. The OUTPUT clause uses the Deleted virtual table to populate the fields in the @DeletedTable variable.

       

      Now please look at the bold portion of the code snippet: it gives an error telling

        Msg 170, Level 15, State 1, Line 2

      Line 2: Incorrect syntax near 'OUTPUT'.

       

      What is the wrong in the syntax?

       

      CREATE TABLE OutputTest

      (

         KeyID INT Identity,

         Name CHAR(20)

      )

      GO

       

      INSERT INTO OutputTest (Name)

         Values ('Jitu')

      INSERT INTO OutputTest (Name)

         Values ('Mark')

      INSERT INTO OutputTest (Name)

         Values ('Ravi')

      INSERT INTO OutputTest (Name)

         Values ('Rajeev')

      INSERT INTO OutputTest (Name)

         Values ('Asish')

      GO

       

      DECLARE @DeletedTable TABLE

      (

         DeletedTableID INT,

         DeletedData  VARCHAR(20)

      )

      SELECT * from @DeletedTable

       

       

      DELETE OutputTest

      OUTPUT

         Deleted.KeyID,

         Deleted.Name

      INTO @DeletedTable

      WHERE KeyID > 2

       

       

      DELETE OutputTest

          OUTPUT DELETED.* INTO @DeletedTable;

       

       

       

       

      Thanks & Regards,

      Avik

      Every search begins with beginner's luck. And every search ends with the victors being severely tested.

       

    • harsh kumar
      Hi Group, Please suggest how we can execute and get the result on TB size database, already facing issue with high utilization of resource. Thanks Harsh
      Message 2 of 2 , Dec 14, 2010
      • 0 Attachment
        Hi Group,








        Please suggest how we can execute and get the result on TB size database, already facing issue with high utilization of resource.
        Thanks
        Harsh




        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.