Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Name Table with Now() function

Author  Topic 

RooHoo
Starting Member

11 Posts

Posted - 2003-03-21 : 09:15:41
I need to export a file with today's date added on to the name, ie.
Disconnect_mmddyy.xls.

In my CREATE TABLE for Access the code is
"Disconnect_" & Format$(Now(), "mmddyy") & ".xls", False

How do you write it for SQL?
Thanks


Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-21 : 09:23:18
Take a look at GETDATE() or current_timestamp

Jay White
{0}
Go to Top of Page

RooHoo
Starting Member

11 Posts

Posted - 2003-03-21 : 09:39:11
This doesn't work,
Can you give me the syntax,

CREATE TABLE `DisconnectCompDaily`&`GetDate()`

Go to Top of Page

RooHoo
Starting Member

11 Posts

Posted - 2003-03-21 : 09:44:32
When I try to export it out using the Excel icon, it makes you put a file name, which is what the file name will be, it doesn't take the new date on the end of it.
Thanks

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-21 : 09:48:37
Excel icon? What are you talking about? Are you trying to create a DTS package?

To dynamically set source and destination connections in a dts package look here

Jay White
{0}
Go to Top of Page

RooHoo
Starting Member

11 Posts

Posted - 2003-03-21 : 10:00:00
Yes, a DTS package.
After I have my connection ICON, then do I put the ACTIVE script (with the code on the link you sent me) and then the excel icon?
I know this is VERY basic for some of you, but for NEWBIES it is quite confusing.
Thanks so much for all of you help!


Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-03-21 : 10:09:16
You really should consider buying a good book on DTS. IMHO, it is not very easy to work with and is quite confusing. nr will tell you to avoid it at all costs.

Follow these steps.
1.) Open a new dts package.
2.) Create a Connection to you SQL Server.
3.) Create a Connection to an excel spreadsheet (call it DisconnectCompDailyTest.xls for now)
4.) Set up the transform data task and prove you can export from a table to excel.
5.) Create an ActiveX Scripting Task using the code in the link to set the name of you excel spreadsheet at runtime.
6.) Create a precedence constriant such that you ActiveX Scripting Task runs before your Transform Data Task.

Jay White
{0}
Go to Top of Page

RooHoo
Starting Member

11 Posts

Posted - 2003-03-21 : 13:24:50
I have MS Step by Step SQL Server 2000 Programming. Is there a better one?
Thanks for the code.

Much appreciated!

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-03-21 : 14:21:08
SQLTeam has a list of books that they recommend for SQL Server. Here is the one for DTS:

[url]http://www.amazon.com/exec/obidos/ASIN/1861004419/sqlteamcom-20/002-3500965-1498427[/url]

Tara
Go to Top of Page
   

- Advertisement -