From: Pat on 2 Jun 2010 18:25 Hi Friends, I'm using sql command scripting like this : GO :setvar ClientPortalName "Patrick" :setvar DatabaseName "ces_" :setvar DefaultDataPath "F:\Data\" :setvar DefaultLogPath "G:\DATA\" use master go print N'$(DatabaseName)' RESTORE DATABASE [$(DatabaseName)] FROM DISK = N'H:\Backup\backup.BAK' WITH FILE = 1, MOVE N'ces_default_Data' TO N'F:\Data\ces_Patrick.mdf', MOVE N'ces_default_Log' TO N'G:\DATA\ces_Patrick.ldf', NOUNLOAD, STATS = 1 , REPLACE GO My question is that how can I set server variables and have calculated. something like : :setvar DatabaseName+ClientPortalName which I'm excpeting the result of ces_Patrick Thanks in advance, Pat
From: John Bell on 3 Jun 2010 04:53 On Wed, 2 Jun 2010 15:25:56 -0700 (PDT), Pat <patrickalexander.email(a)gmail.com> wrote: >Hi Friends, >I'm using sql command scripting like this : > >GO >:setvar ClientPortalName "Patrick" >:setvar DatabaseName "ces_" >:setvar DefaultDataPath "F:\Data\" >:setvar DefaultLogPath "G:\DATA\" > >use master >go >print N'$(DatabaseName)' > >RESTORE DATABASE [$(DatabaseName)] >FROM DISK = N'H:\Backup\backup.BAK' >WITH FILE = 1, >MOVE N'ces_default_Data' TO N'F:\Data\ces_Patrick.mdf', >MOVE N'ces_default_Log' TO N'G:\DATA\ces_Patrick.ldf', >NOUNLOAD, STATS = 1 , REPLACE >GO > >My question is that how can I set server variables and have >calculated. >something like : > >:setvar DatabaseName+ClientPortalName > >which I'm excpeting the result of ces_Patrick > >Thanks in advance, >Pat :setvar ClientPortalName "Patrick" :setvar DatabaseName "ces_" :setvar DefaultDataPath "F:\Data\" :setvar DefaultLogPath "G:\DATA\" Hi Try: use master go print N'$(DatabaseName)' RESTORE DATABASE [$(DatabaseName)] FROM DISK = N'H:\Backup\backup.BAK' WITH FILE = 1, MOVE N'ces_default_Data' TO N'$(DefaultDataPath)$(DatabaseName)$(ClientPortalName).mdf', MOVE N'ces_default_Log' TO N'$(DefaultLogPath)$(DatabaseName)$(ClientPortalName).ldf', NOUNLOAD, STATS = 1 , REPLACE GO John
|
Pages: 1 Prev: How to use GO with a sql string Next: MonthName Year to YYYYMM Conversion |