dbTalk Databases Forums  

Using variable in system stored procedure

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


Discuss Using variable in system stored procedure in the microsoft.public.sqlserver.dts forum.



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

Default Using variable in system stored procedure - 03-01-2004 , 02:41 AM






Hi,
I need to import an excel file every month. The excel file should be imported into a table named 'NewInforec', and the existing table should be renamed to 'NewInforec_(month -1)

At this time I have this code

DECLARE @month INT

SET @month = DATEPART(mm, GETDATE())

DROP TABLE NewInforec_ol

EXEC sp_rename 'NewInforec', 'NewInforec_' <---Here the month variable should appear

CREATE TABLE [NewInforec] ( .........

My question is now: How do I put @month variable at the end of 'NewInfore_' ??

I am sure this is simple for guys like you to explain this to me

TI

/Gulkings

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

Default Re: Using variable in system stored procedure - 03-01-2004 , 04:16 AM






You can build up the statement in an Active Script task

Global Variables and SQL statements in DTS
(http://www.sqldts.com/Default.aspx?205)

--

----------------------------

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


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

Quote:
Hi,
I need to import an excel file every month. The excel file should be
imported into a table named 'NewInforec', and the existing table should be
renamed to 'NewInforec_(month -1)'
Quote:
At this time I have this code:

DECLARE @month INT;

SET @month = DATEPART(mm, GETDATE());

DROP TABLE NewInforec_old

EXEC sp_rename 'NewInforec', 'NewInforec_' <---Here the month variable
should appear !

CREATE TABLE [NewInforec] ( .........)

My question is now: How do I put @month variable at the end of
'NewInfore_' ???

I am sure this is simple for guys like you to explain this to me.

TIA

/Gulkings



Reply With Quote
  #3  
Old   
gulkings
 
Posts: n/a

Default Re: Using variable in system stored procedure - 03-01-2004 , 05:16 AM



Surely, there must be a more simple way of doing this ??? I am using SQL Server 7.0

----- Allan Mitchell wrote: ----

You can build up the statement in an Active Script tas

Global Variables and SQL statements in DT
(http://www.sqldts.com/Default.aspx?205

--

---------------------------

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP
www.allisonmitchell.com - Expert SQL Server Consultancy
www.SQLDTS.com - The site for all your DTS needs
I support PASS - the definitive, global communit
for SQL Server professionals - http://www.sqlpass.or


"gulkings" <anonymous (AT) discussions (DOT) microsoft.com> wrote in messag
news:BAB3B771-EBFA-4C41-9718-F742DBFEF346 (AT) microsoft (DOT) com..
Quote:
Hi
I need to import an excel file every month. The excel file should b
imported into a table named 'NewInforec', and the existing table should b
renamed to 'NewInforec_(month -1)
Quote:
At this time I have this code
DECLARE @month INT
SET @month = DATEPART(mm, GETDATE())
DROP TABLE NewInforec_ol
EXEC sp_rename 'NewInforec', 'NewInforec_' <---Here the month variabl
should appear
CREATE TABLE [NewInforec] ( .........
My question is now: How do I put @month variable at the end o
'NewInfore_' ??
I am sure this is simple for guys like you to explain this to me
TI
/Gulking




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.