INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...Congratulations on a brilliant idea and a great site..."

Geography

Where in the world do Tek-Tips members come from?
ttrsux (IS/IT--Management)
14 Sep 09 11:58
I have used this script on multiple SQL servers, 2000 and 2005. I have a SQL 2000 server (w2k3 R2 SP2) which I have been unable to get any sort of automated backup working for months. I have to right-click each DB (about 20 of them) and choose ALL TASKS --> BACKUP DATABASE just to back them up.

Every time I set aside time to work on it, I encounter the same thing as before and not really sure where to start. Event viewer gives me nothing but I do get a WSH error...

[IMG]http://i632.photobucket.com/albums/uu44/sunspotresorts/SQL_ERROR.jpg[/IMG]

Here is the script with the server name and password replaced with SERVER and PASSWORD:

--------------------------------------------------------

Dim Server(0)
Server(0) = "DRIVER={SQL Server};Server=SERVER;Database=master;uid=SQLBackup;pwd=PASSWORD"

Dim BackupLocation(0)
BackupLocation(0) = "F:\Baks"

Dim Exclusions(0)
Exclusions(0) = ""


For t = 0 to UBOUND(Server)
    set Connection = CreateObject("ADODB.Connection")
    Connection.Open Server(t)
    set rs = CreateObject("ADODB.Recordset")
    rs.Open "select name, status from sysdatabases where UPPER(name) not in ('master', 'model', 'msdb', 'tempdb')", Connection, 3, 2, 1
    Do
        myExclusions = Split(Exclusions(t), ",")
        FoundExclusion = False
        For x = 0 to UBOUND(myExclusions)
            If UCASE(myExclusions(x)) = UCASE(rs.fields("name")) Then FoundExclusion = true
        Next


        
If FoundExclusion = False Then Connection.Execute "BACKUP DATABASE [" & rs.fields("name") & "] TO  DISK = N'" & BackupLocation(t) & rs.fields("name") & ".bak' WITH  INIT ,  NOUNLOAD ,  NAME = N'" & rs.fields("name") & " backup',  NOSKIP ,  STATS = 10,  NOFORMAT"


        rs.movenext
    Loop Until rs.EOF
    rs.Close
    Connection.Close
Next

--------------------------------------------------------
Check Out Our Whitepaper Library. Click Here.
hmckillop (Programmer)
14 Sep 09 16:13
A couple of things not sure will help- is "Connection" not a reserved word?
eg. replace connection with dbConn or something else

As a one off replace your Connection.Open Server(t) with

Connection.open "Server(0) = "DRIVER={SQL Server};Server=SERVER;Database=master;uid=SQLBackup;pwd=PASSWORD"

And see if this works.

Also make sure you password and login can access the Master DB and its not just a user for the DB you are trying to backup.

After that another option is to try and setup a file DSN and use the connection data from that to build your connection string.


 

"I'm living so far beyond my income that we may almost be said to be living apart"

Crowley16 (TechnicalUser)
15 Sep 09 12:13
looking at your error message, it seems pretty obvious that your connection string is wrong.

look at www.connectionstrings.com and check your username/passwords.

If that doesn't work, check that your server is setup to allow remote connections.

--------------------
Procrastinate Now!

ttrsux (IS/IT--Management)
15 Sep 09 13:25
thanks for the replies... i'll check on both and report back asap.

Start A New Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Promoting, selling, recruiting and student posting
are not allowed in the forums.
Posting Policies

LINK TO THIS FORUM!
(Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum)
TITLE: Microsoft SQL Server: Programming Forum at Tek-Tips
URL: http://www.tek-tips.com/threadminder.cfm?pid=183
DESCRIPTION: Microsoft SQL Server: Programming technical support forum and mutual help system for computer professionals. Selling and recruiting forbidden.