Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Script to update SQL

Author  Topic 

MassiveOverkill
Starting Member

20 Posts

Posted - 2008-01-15 : 14:03:19
EDIT: got it figured out, nevermind


I am trying to write a script that will apply a service pack if the existing version isn't up to date. I've got most of the code, but need some help. Here is the script:

ECHO ON

NET START SQLBROWSER

"%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\SQLCMD" -S "127.0.0.1\(myinstance)" -Q "SELECT @@VERSION" | FINDSTR "9.00.3152.00"

IF %ERRORLEVEL% EQU 0 GOTO SQLUPDATED

IF %ERRORLEVEL% EQU 1 GOTO SQLNEEDSUPDATED

:SQLUDPATED

ECHO SQL IS UP TO DATE

PAUSE

GOTO END

:SQLNEEDSUPDATED

ECHO SQL NEEDS TO BE UPDATED, APPLYING UPDATE NOW

ECHO PLEASE BE PATIENT AS THIS MAY TAKE A FEW MINUTES TO UPDATE SQL WITH THE LATEST SERVICE PACK

sqlserver2005-kb933097-x86-enu.exe /quiet /allinstances

PAUSE

GOTO END

:END

NET STOP SQLBROWSER


The service pack file will be located in the same directory as the batch file.
I appreciate any help

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-01-15 : 16:17:31
moved from script library

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -