Morning,I am trying to set up a snapshot database script that will dynamically assign a name to the database. Like every month I have to create a snapshot like so: PYYYYMM so February would be P201002 I have the following script for the snapshot:CREATE DATABASE P201002 ON( NAME = Production_Data, FILENAME = 'D:\SQLBackups\ProductionBackup')AS SNAPSHOT OF Production;GO
and I have the following to get the right format for the database name:select 'P'+CAST(YEAR(GETDATE()) AS VARCHAR(4)) + left(CONVERT ( char(20) , getdate() , 101 ),2)as datetime
My question is how can I put them together?Thanks for any help you can provide.Laura