Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to Master SQL
Message
De
13/08/2004 15:36:37
Evans Carl
System Answers Consulting, Inc
Big Lake, Minnesota, États-Unis
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Trying to Master SQL
Divers
Thread ID:
00933227
Message ID:
00933227
Vues:
59
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,
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform