dbTalk Databases Forums  

DTS CREATE TABLE dynamically

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


Discuss DTS CREATE TABLE dynamically in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DJJ
 
Posts: n/a

Default DTS CREATE TABLE dynamically - 12-19-2003 , 06:06 AM






Howdy all,

I'm trying to use DTS to output the results from a
dynamically generated query into Excel and email the
resultant .xls file directly to the requesting user (the
users will be able to choose from a list of 'Reports' and
supply values to be used in the WHERE clause). I've
gotten everything to work up to the point of dynamically
creating the table in DTS to allow DTS to copy the data
from SQL to the .xls file (If I use the same base query,
just changing the WHERE clause, it works like a charm) -
does anyone know of a way to basically have SQL look at a
query, create a table (dynamically) based on the fields
in the query, and use that as the CREATE TABLE definition
in DTS? It must be possible since the DTS Wizard seems
to be able to do it on-the-fly when you select a table to
output... My other option was to create a DTS package for
each query-type, but I'd rather not do that if I can help
it.

Not sure how clear I've been....

Using SQLServer 2k, SP3.

Thanks


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: DTS CREATE TABLE dynamically - 12-19-2003 , 06:21 AM






You need to read the query and build the statement so

SELECT au_id, au_lname FROM AUTHORS

Would parse to

CREATE TABLE AUTHORS (au_id varchar(255), au_lname varchar(255))

You can easily do this in VBScript. I have a package which does exactly
what you want at home but I am not on the internet so cannot grab it. I
will bring it in monday if you want. Drop me a mail (without no-spam)


--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"DJJ" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Howdy all,

I'm trying to use DTS to output the results from a
dynamically generated query into Excel and email the
resultant .xls file directly to the requesting user (the
users will be able to choose from a list of 'Reports' and
supply values to be used in the WHERE clause). I've
gotten everything to work up to the point of dynamically
creating the table in DTS to allow DTS to copy the data
from SQL to the .xls file (If I use the same base query,
just changing the WHERE clause, it works like a charm) -
does anyone know of a way to basically have SQL look at a
query, create a table (dynamically) based on the fields
in the query, and use that as the CREATE TABLE definition
in DTS? It must be possible since the DTS Wizard seems
to be able to do it on-the-fly when you select a table to
output... My other option was to create a DTS package for
each query-type, but I'd rather not do that if I can help
it.

Not sure how clear I've been....

Using SQLServer 2k, SP3.

Thanks




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.