Results 1 to 2 of 2

Thread: How to Execute

  1. #1
    Join Date
    Aug 2003
    Posts
    1

    Unanswered: How to Execute

    My Question:

    If we execute Query (Text Format), Im getting Insert statements in result set

    Right Now; I'm doing, Copy and Paste the result set in Query window and again running the query to insert into Table.

    Is there any way, to execute it Dynamically(instead of copy & paste)

    can Any one help with this.

    Look into this query:

    SET NOCOUNT ON

    USE PUBS
    GO

    Drop Table ##Temp1
    GO
    Create Table ##Temp1 ( X Varchar (22), Name Varchar (30), Z Varchar (30))

    Insert into ##Temp1
    select 'select count(*) from ' AS X, Name AS Y, 'Insert into ##1' AS Z
    from sysobjects where xtype = 'u'
    order by name

    -- SELECT * FROM ##Temp1

    Drop Table ##1
    go
    Create Table ##1(Table_Name Varchar(50), No_Of_Rows Int)

    select Z + char(10) + 'Select '+ '"' + A.Name + '" ' + 'As Table_Name, ' +
    'count(*) As No_of_Rows from '+ A.Name
    from sysobjects A , ##Temp1 B
    where A.Name = B.Name and xtype = 'U'
    order by A.Name

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: How to Execute

    EXECUTE should execute your SQL statement
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •