dbTalk Databases Forums  

execute into table

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss execute into table in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
fumi.omotayo@ecovertfm.com
 
Posts: n/a

Default execute into table - 01-14-2004 , 06:39 AM






is it possible to execute into a table.
i.e store the output of the code below into a table

DECLARE tables_cursor CURSOR FOR
SELECT distinct tbname FROM maxsyscolumns
OPEN tables_cursor
DECLARE @tablename varchar(30)
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@fetch_status <> -1)
BEGIN
declare @tname varchar(128) set @tname = @tablename
EXEC ('Select '''+ @tname +''', count(*) from '+@tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor

many thanks

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: execute into table - 01-14-2004 , 08:05 AM






Change the EXEC's statement to use an INSERT of the SELECT

INSERT MyTable
SEKECT COUNT(*) FROM Table

How does this relate to DTS?


--
Darren Green
http://www.sqldts.com


"fumi.omotayo (AT) ecovertfm (DOT) com" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message news:087d01c3da9b$6e1f7fd0$a601280a (AT) phx (DOT) gbl...
Quote:
is it possible to execute into a table.
i.e store the output of the code below into a table

DECLARE tables_cursor CURSOR FOR
SELECT distinct tbname FROM maxsyscolumns
OPEN tables_cursor
DECLARE @tablename varchar(30)
FETCH NEXT FROM tables_cursor INTO @tablename
WHILE (@@fetch_status <> -1)
BEGIN
declare @tname varchar(128) set @tname = @tablename
EXEC ('Select '''+ @tname +''', count(*) from '+@tablename)
FETCH NEXT FROM tables_cursor INTO @tablename
END
DEALLOCATE tables_cursor

many thanks



Reply With Quote
  #3  
Old   
Nigel Rivett
 
Posts: n/a

Default execute into table - 01-14-2004 , 08:06 AM



see
http://www.nigelrivett.net/sp_executeSQL.html

and

http://www.nigelrivett.net/sp_GetRowsForAllTables.html

(the second doesexactly what you want to do).

Also consider
insert tbl select o.name, i.rows from sysindexes i,
sysobjects o where i.id = o.id and i.indid in (0,1) and
o.name in (select tbname from maxsyscolumns)

You will need to update the values first to make sure of
the count in the table if you want it to be accurate.

Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.