All,
I have this process that I would like to select the name of an archive database the was just created archive SQL script. The problem is that I do not know the complete name because the date is attach to the name.
SET @ArchDatabase = 'Archiveme' + CAST(DATEPART(month,@dtLogTime) as varchar(10)) + CAST(DATEPART(day,@dtLogTime) as varchar(10))+ CAST(DATEPART(year,@dtLogTime) as varchar(10))
When I tried to do the following to select this database
SET @SQL = 'SELECT * FROM sysdatabases WHERE name like '''+ @ArchDatabase + ''''
EXEC (@SQL)
IF @@ROWCOUNT > 0
BEGIN
SET @SQLDatabase = 'USE ' + @ArchDatabase
EXEC (@SQLDatabase)
END
The database remains UNSELECTED.
Is there another way to attack this problem, then the way I'm going about it. I know I can redo this in a DTS job with ActiveX scripting, but I hoping that I can accomplish it this way.
Thanks,
Carl
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°¤º°`°º¤ø¤º°¤º°
Carl Evans
CEO & President
System Answers Consulting, Inc.
MCSD .NET, ASP.NET, C#.NET, VB.NET,