Showing posts with label masterexec. Show all posts
Showing posts with label masterexec. Show all posts

Sunday, March 11, 2012

BackUp database

Hi all

I use this code to bak up database
and its working fine but i want run this code via ASP
can anyone write it for me in ASP format?

USE master
EXEC sp_addumpdevice 'disk', 'test_2',
'C:\test_2.dat'

USE master
EXEC sp_addumpdevice 'disk', 'testlog',
'C:\testlog.dat'

BACKUP DATABASE test TO test_2

BACKUP LOG test TO testlog



thanksAll you need to do is put each TSQL command as relevant ASP command.
In your case, you need to execute 4 commands so you would need
SQLStmt, SQLstmt1,2,3 and 4 lots of RS = Connection.Execute(SQLStmt)

e.g. - example of one connection & execution :

Dim UID
Dim SQLStmt, SQLStmt1, SQLStmt2, SQLStmt3
Dim Connection,
Dim RS, RS1, RS2, RS3

Set Connection = Server.CreateObject("ADODB.Connection")

Connection.Open "PROVIDER=SQLOLEDB;DATA SOURCE=server1;UID=test;PWD=password;DATABASE=data base1"

SQLStmt = "SELECT * FROM TBL_Test where server_name = 'SERVER1' and job_run_time > (getdate() - 7)"

Set RS = Connection.Execute(SQLStmt)

Sunday, February 12, 2012

Backing up tr.log on another server

In the main server(for example, THIS_SERVER):
USE master
EXEC sp_addumpdevice 'disk', 'INTERMEDIATE_LOG_DEVICE',
'\\ANOTHER_SERVER_NAME\C:\SOME_FOLDER_NA
ME\ INTERMEDIATE_LOG.DAT'
Everything is normal
I wanted to back up trans. log on the another server in the local net, but
failed.
BACKUP LOG INTERMEDIATE
TO INTERMEDIATE_LOG_DEVICE
WITH NO_TRUNCATE
Server: Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'INTERMEDIATE_LOG_DEVICE'. Device error or device
off-line. See the SQL Server error log for more details.
Server: Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.
Could you advice me, how I can solve this problem?
If I back up in the same server - everything is well.I think the problem is with the path. The : could be replaced with a $, as
show below:
'\\ANOTHER_SERVER_NAME\C$\SOME_FOLDER_NA
ME\ INTERMEDIATE_LOG.DAT'
Even better, why not create a proper share and use the share name instead.
For example: \\ServerName\ShareName ?
Also make sure the SQL Server and Agent service accounts have access to this
share.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Alur" <Alur@.discussions.microsoft.com> wrote in message
news:3D089089-AC83-4006-B446-93215CDEE3F6@.microsoft.com...
In the main server(for example, THIS_SERVER):
USE master
EXEC sp_addumpdevice 'disk', 'INTERMEDIATE_LOG_DEVICE',
'\\ANOTHER_SERVER_NAME\C:\SOME_FOLDER_NA
ME\ INTERMEDIATE_LOG.DAT'
Everything is normal
I wanted to back up trans. log on the another server in the local net, but
failed.
BACKUP LOG INTERMEDIATE
TO INTERMEDIATE_LOG_DEVICE
WITH NO_TRUNCATE
Server: Msg 3201, Level 16, State 1, Line 1
Cannot open backup device 'INTERMEDIATE_LOG_DEVICE'. Device error or device
off-line. See the SQL Server error log for more details.
Server: Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.
Could you advice me, how I can solve this problem?
If I back up in the same server - everything is well.|||You might also need the right permissions on \\ANOTHER_SERVER_NAME\C$
(usually available for admins).
In order to create a connection to a remote disk you can run:
EXEC xp_cmdshell 'net use \\ANOTHER_SERVER_NAME\C$ the_account_password
/USER:THE_ACCOUNT_DOMAIN\TheUserAccount'
Where TheUserAccount has the right access on C$.
BTW: make sure the whole command is in one line
Lionel Chacon
"Narayana Vyas Kondreddi" wrote:

> I think the problem is with the path. The : could be replaced with a $, as
> show below:
> '\\ANOTHER_SERVER_NAME\C$\SOME_FOLDER_NA
ME\ INTERMEDIATE_LOG.DAT'
> Even better, why not create a proper share and use the share name instead.
> For example: \\ServerName\ShareName ?
> Also make sure the SQL Server and Agent service accounts have access to th
is
> share.
> --
> HTH,
> Vyas, MVP (SQL Server)
> SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
>
> "Alur" <Alur@.discussions.microsoft.com> wrote in message
> news:3D089089-AC83-4006-B446-93215CDEE3F6@.microsoft.com...
> In the main server(for example, THIS_SERVER):
> USE master
> EXEC sp_addumpdevice 'disk', 'INTERMEDIATE_LOG_DEVICE',
> '\\ANOTHER_SERVER_NAME\C:\SOME_FOLDER_NA
ME\ INTERMEDIATE_LOG.DAT'
> Everything is normal
> I wanted to back up trans. log on the another server in the local net, but
> failed.
> BACKUP LOG INTERMEDIATE
> TO INTERMEDIATE_LOG_DEVICE
> WITH NO_TRUNCATE
> Server: Msg 3201, Level 16, State 1, Line 1
> Cannot open backup device 'INTERMEDIATE_LOG_DEVICE'. Device error or devic
e
> off-line. See the SQL Server error log for more details.
> Server: Msg 3013, Level 16, State 1, Line 1
> BACKUP LOG is terminating abnormally.
> Could you advice me, how I can solve this problem?
> If I back up in the same server - everything is well.
>
>|||Thank you very much.
I tried to use
\\ANOTHER_SERVER_NAME\C$ and so on
but the result is the same.
Maybe I must reinstall SQL Server with some another
characteristices(options) ?
"Lionel Chacon" wrote:
> You might also need the right permissions on \\ANOTHER_SERVER_NAME\C$
> (usually available for admins).
> In order to create a connection to a remote disk you can run:
> EXEC xp_cmdshell 'net use \\ANOTHER_SERVER_NAME\C$ the_account_password
> /USER:THE_ACCOUNT_DOMAIN\TheUserAccount'
> Where TheUserAccount has the right access on C$.
> BTW: make sure the whole command is in one line
> --
> Lionel Chacon
>
> "Narayana Vyas Kondreddi" wrote:
>