If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > How to Execute

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-03, 16:48
Hot_Tech Hot_Tech is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
How to Execute

My Question:

If we execute Query (Text Format), I’m 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
Reply With Quote
  #2 (permalink)  
Old 08-26-03, 02:58
DoktorBlue DoktorBlue is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On