Nov 27 2009

I just signed up to receive em…

I just signed up to receive emails from DefeatTheDebt.com YOU SHOULD TOO.

Nov 26 2009

I saw The Blind Side on Monday…

I saw The Blind Side on Monday and it was FANTASTIC.

Nov 18 2009

SQL Server cursor syntax

declare VARIABLES

declare CURSOR_NAME cursor local static for SELECT STATEMENT
open CURSOR_NAME
fetch next from CURSOR_NAME into VARIABLES –EXAMPLE –VAR1,VAR2 –SELECT STATEMENT RETURNS MATCHING COLUMNS FOR EACH VAR
while @@FETCH_STATUS = 0
begin
–DO STUFF
–YOU CAN SELECT IN TO OTHER VARIABLES
–OR IF @@ROWCOUNT > 0 OR OTHER IF STATEMENTS.
–RUN IUD QUERIES. ETC.

fetch next from CURSOR_NAME into VARIABLES
end
close CURSOR_NAME
deallocate CURSOR_NAME

–written here for posterity

Nov 17 2009

Just put a new floor in our do…

Just put a new floor in our down half-bath for the 2nd time . On Thursday a PLUMBER is coming to install the rest so to avoid a repeat.

Nov 17 2009

My Subversion Global Ignore List

If you use Tortoise SVN you need a global ignore list so that your source code won’t change just by building a project or opening your IDE. Here is the global ignore list that I use.

*.suo *\bin *\obj *\bin\* *\obj\* *.resharper *.user _ReSharper* *.cache *.log *.vspscc *.vssscc *\build_output *\build_output\* *\code_drop *\code_drop\* SolutionVersion.cs SolutionVersion.vb* *\ MeetingManagerDXCore.Solution *\MeetingManagerDXCore.Solution*

A lot of the above settings are if you use Dev Express Refactor Pro and some specific to some of my projects.

Here is a plain vanilla global ignore list if you use Visual Studio.

*.suo *\bin *\obj *\bin\* *\obj\* *.resharper *.user *.cache *.log *.vspscc *.vssscc

Seth

Nov 16 2009

What’s your states fiscal heal…

What’s your states fiscal health? http://tinyurl.com/yj9fag6

Nov 16 2009

I am reading John Mauldin’s ex…

I am reading John Mauldin’s excellent newsletter… http://tinyurl.com/ykree5r . To subscribe…http://tinyurl.com/2y9r3k.

Nov 12 2009

SQL Script and Batch file for recovering user databases if SQL Server won’t start because Master db is corrupt

Sorry for the long title.

Sometimes your SQL Server installation is corrupt. You read the logs and the error says that your the MASTER database won’t start. And…oops…you don’t have a recent backup of your all-important user database.

Maybe running this batch file will work.

REM repairMaster.bat

@echo off

REM CHANGE THE filepath variable below. If you have multiple sql instances the path below might not work.
REM UPDATE THE FOLLOWING VARIABLES TO MATCH YOUR NEED.
set file-path=C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL
set backup-path=C:\SQL_data_recovery
set db-file-name=DBNAME.mdf
set log-file-name=LOGNAME.ldf
set db-name=DBNAME
set instance-name=INSTANCENAME
set server-name=SERVERNAME

echo %file-path%\mastlog.ldf

del “%file-path%\Data\master.mdf”
del “%file-path%\Data\mastlog.ldf”

md %backup-path%

REM **JUST IN CASE GRAB THE TWO DATA FILES of your database. Since your server won’t start these files are not locked.
copy “%file-path%\Data\%db-file-name%” %backup-path%
copy “%file-path%\Data\%log-file-name%” %backup-path%

copy “%file-path%\Template Data\master.mdf” “%file-path%\Data\master.mdf”
copy “%file-path%\Template Data\mastlog.ldf” “%file-path%\Data\mastlog.ldf”
copy “%file-path%\Template Data\model.mdf” “%file-path%\Data\model.mdf”
copy “%file-path%\Template Data\modellog.ldf” “%file-path%\Data\modellog.ldf”
copy “%file-path%\Template Data\msdbdata.mdf” “%file-path%\Data\msdbdata.mdf”
copy “%file-path%\Template Data\msdblog.ldf” “%file-path%\Data\msdblog.ldf”

net start %instance-name%

sqlcmd -S%server-name% -Usa -irepairMaster.sql

echo DONE

OF COURSE, YOU HAVE TO UPDATE THE VARIABLES at the beginning of the batch file to match your needs.

It won’t work if you don’t put put the following SQL Script into same folder you put the BAT file.

–repairMaster.sql

use master
go

DECLARE @filepathDB nvarchar(100);
DECLARE @filepathLog nvarchar(100);

SET @filepathDB = ‘$(file-path)\Data\$(db-file-name)’
SET @filepathLog = ‘$(file-path)\Data\$(log-file-name)’

exec sp_attach_db ‘$(db-name)’,@filepathDB,@filepathLog
go

BACKUP DATABASE $(db-name) TO DISK=’$(backup-path)\$(db-name)_backup.bak’
GO
RESTORE VERIFYONLY FROM DISK=’$(backup-path)\$(db-name)_backup.bak’
GO

Sorry…no time to explain. To download click here.

Seth

Nov 12 2009

Just ordered Money, Greed, and…

Just ordered Money, Greed, and God: Why Capitalism Is the Solution and Not the Problem http://tinyurl.com/yb63vp7

Nov 11 2009

Comment by Seth Spearman on SQL Server add a column constraint to limit data to -1 to 1

Your right…it is an int not a decimal.