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
 SQL Server Development (2000)
 Selecting from a changing file name

Author  Topic 

hjyoungii
Starting Member

3 Posts

Posted - 2007-05-15 : 09:35:39
We are using SQL 2000 and need to be able to select from a file that changes each month.

example: abc0107 abc0207 abc0307

These files are coming from an AS400. I have a link to the AS400 server but am having problems with the naming issue.

sshelper
Posting Yak Master

216 Posts

Posted - 2007-05-15 : 10:21:19
You can use dynamic SQL for your SELECT statement:

DECLARE @SQL VARCHAR(200)
SET @SQL = 'SELECT * FROM abc' + CONVERT(VARCHAR(2), GETDATE(), 2) + CONVERT(VARCHAR(2), GETDATE(), 1)

EXECUTE (@SQL)

SQL Server Helper
http://www.sql-server-helper.com
Go to Top of Page
   

- Advertisement -