Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 5th, 2006, 10:36 AM
Registered User
 
Join Date: Apr 2006
Location: evansville, in, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default dynamically changing the destination table

Hi:



I want to create a dts package and schedule to run every week like
this:



The Server name A. It has a table abc. I want to collect the one week
data from table abc and

has to load to server B with table name abc060322. Next week I have to
load the data with table name abc060329.



I wrote the query to create dynamic table every week: The query is



DECLARE @TableName VARCHAR(100)

SET @TableName = convert(varchar(11),getdate(),12)

--print @tablename



/*DECLARE @pos INT

SELECT @pos = CHARINDEX('/',@tablename)



WHILE @pos > 0

BEGIN

SELECT @tablename = SUBSTRING(@tablename,1,@pos - 1) +

SUBSTRING(@tablename,@pos + 1,50-@pos )

SELECT @pos = CHARINDEX('/',@tablename)

END

-- PRINT 'Name without DASHES is :'

-- PRINT @tablename*/

SELECT @tablename = 'GISLOADER.ACC' + @tablename

DECLARE @StrSQL VARCHAR(2000)

SET @StrSQL = ('CREATE TABLE ' + @tablename + '([CV_INSERT_IDENTITY] int
null,

     [RecordID] [int] IDENTITY (1, 1) NOT NULL ,

     [_TimeStamp] [timestamp] NULL ,

     [ACCSUnit] [varchar](20)NULL ,

     [ACCSDir] [varchar](20) NULL ,

     [ACCLName] [varchar](20)NULL ,

     [ACCSZip] [varchar](20) NULL ,

     [ACCSState] [varchar](20)NULL ,

     [ACCSCity] [varchar](20)NULL ,

     [ACCSType] [varchar](20)NULL ,

     [ACCPhone] [varchar](20)NULL ,

     [ACCSName] [varchar](20)NULL ,

     [ACCSNum] [varchar](20)NULL ,

     [ACCFName] [varchar](20)NULL ,

     [ACCCompType] [varchar](4)NULL ,

     [ACCEmail] [varchar](40)NULL ,

     [ACCTimeResolved] [datetime]NULL ,

     [ACCTimeofCall] [datetime]NULL ,

     [ACCDateResolved] [datetime]NULL ,

     [ACCDateofCall] [datetime]NULL ,

     [ACCOfficer][varchar](4)NULL ,

     [ACCFine] [bit] NULL ,

     [ACCViolation][varchar](4)NULL ,

     [ACCFineAmt][money]NULL,

     [ACCPet] [int] NULL ,

     [ACCResStatus] [varchar] (4) NULL ,

     [ACLSZip] [varchar](20) NULL ,

     [ACLSCity] [varchar](20)NULL ,

     [ACLSType] [varchar](20)NULL ,

     [ACLSName] [varchar](20)NULL ,

     [ACLSNum] [varchar](20)NULL ,

     [ACLSUnit] [varchar](20)NULL ,

     [ACLSState] [varchar](20)NULL ,

     [ACLSDir] [varchar](20)NULL ,

     [ParcelID] [int] NULL ,

     [CitationNo] [varchar](20)NULL ,

     [PickUpCat] [smallint]NULL ,

     [PickUpDog] [smallint]NULL ,

     [PickUpOther] [smallint]NULL ,

     [Contact] [bit] NULL )')

EXEC (@StrSQL) --> this creates the table



select @tablename.



I wrote the query for selecting the weekly data too:



select [CV_INSERT_IDENTITY] ,

     [RecordID],

     [_TimeStamp],

     [ACCSUnit] ,

     [ACCSDir] ,

     [ACCLName],

     [ACCSZip] ,

     [ACCSState] ,

     [ACCSCity] ,

     [ACCSType],

     [ACCPhone] ,

     [ACCSName],

     [ACCSNum] ,

     [ACCFName],

     [ACCCompType],

     [ACCEmail],

     [ACCTimeResolved],

     [ACCTimeofCall] ,

     [ACCDateResolved] ,

     [ACCDateofCall] ,

     [ACCOfficer] ,

     [ACCFine] ,

     [ACCViolation],

     [ACCFineAmt],

     [ACCPet] ,

     [ACCResStatus],

     [ACLSZip] ,

     [ACLSCity],

     [ACLSType],

     [ACLSName],

     [ACLSNum] ,

     [ACLSUnit] ,

     [ACLSState],

     [ACLSDir] ,

     [ParcelID] ,

     [CitationNo],

     [PickUpCat] ,

     [PickUpDog] ,

     [PickUpOther] ,

     [Contact]

from animalcontrolcalls

where

Accdateofcall >=( getdate() - 7) and ACCdateofcall <= '2500-01-01'



The problem is , I don't how to map the transformation (to pick dynamic
table every week)



The table is going to have the same structure, table name only differs.

I know this can be done thru dynamic properties task. But i don't know how to do it. I am newbie to sql server. Would you please explain step by step thru snapshots


Thank you in advance,



Prema
  #2 (permalink)  
Old April 10th, 2006, 03:37 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , AZ, .
Posts: 146
Thanks: 0
Thanked 1 Time in 1 Post
Default

Prema,

Setup your SQL task that creates the table. Then on the Output Parameter pass the tablename to a global variable. Then setup your Dynamic Properties task (so that it executes after your SQL task and before your Pump task) tell it use the global variable as the source.

An article I wrote has some screenshots of Dynamic properties even though it is not strictly about your problem:
http://www.mutuallybeneficial.com/in...s_portable.htm

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com
 


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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically changing table location csloanATYC BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 November 6th, 2008 02:32 PM
dynamically changing css sarah lee ASP.NET 2.0 Basics 0 January 25th, 2007 10:06 AM
dynamically changing CSS sarah lee CSS Cascading Style Sheets 1 January 25th, 2007 06:14 AM
Dynamically Changing the content of a table cell asdasd Javascript 4 February 18th, 2005 01:44 PM
changing the onclick property dynamically? nerssi Javascript 8 September 21st, 2004 12:59 AM



All times are GMT -4. The time now is 06:16 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.