do as i say, not as i do robert l davis. who am i? no one of consequence

23
Do as I Say, Not as I Do Robert L Davis

Upload: sheryl-bradley

Post on 17-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Do as I Say, Not as I Do

Robert L Davis

Page 2: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Who am I?

No one of consequence.

Page 3: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Time is short!

Please hold all questions until the next

person’s session.

Page 4: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_createsubdir

Page 5: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Exec xp_createsubdir 'c:\bak';• Creates the specified directory path• Doesn’t overwrite existing directories or files• No error if directories already exist• Error only returned if insufficient permissions

Page 6: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_fileexist

Page 7: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Exec xp_fileexist 'c:\bak';Exec xp_fileexist 'c:\bak\db.bak';• Checks for existence of file or folder• File Exists = 1 if a file and exists• File is a Directory = 1 if a folder and exists

Page 8: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_instance_regxxx

Page 9: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_instance_regread;xp_instance_regenumvalues;xp_instance_regenumkeys;

Page 10: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_instance_regwrite;xp_instance_regaddmultistring;

Page 11: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_instance_regremovemultistring;xp_instance_regdeletevalue;xp_instance_regdeletekey;

Page 12: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Declare @BakDir nvarchar(4000),@DefBakDir nvarchar(4000);

Set @Instance = IsNull('\' + Cast(ServerProperty('InstanceName') as sysname), '');Set @DefBakDir = 'E:\mssql\bak' + @Instance;

-- Check default backup locationExec xp_instance_regread N'HKEY_LOCAL_MACHINE',

N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', @BakDir output, 'no_output‘;

-- If default setting null or <> to desired path, setIf IsNull(@BakDir, '') <> @DefBakDir Begin

Exec xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer',N'BackupDirectory',REG_SZ,@DefBakDir;

End

-- Make sure path exists (DUH!)Exec xp_create_subdir @BakDir;

Page 13: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

xp_enumerrorlogsxp_readerrorlogs [#]xp_dirtree 'c:'xp_subdirs 'c:\bak'xp_fixeddrives

Page 14: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Trace flag 3604

Page 15: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC TraceOn(3604);

• Redirects output from the error log to the console• Use with DBCC PAGE

Page 16: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC Ind()

Page 17: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC Ind ('DB', 'Table', Index ID);

• Returns internal info about an indexDBCC Ind

('AdventureWorksDW2008R2','DimAccount',1);

Page 18: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC Page()

Page 19: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC Page ('DB', File #, Page #, Option #);

• Returns internal info about a page• Use with trace flag 3604• Use with DBCC Ind• PageFID = File number• PagePID = Page #

DBCC Page('AdventureWorksDW2008R2', 1, 3458, 3);

Page 20: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

DBCC Page ('DB', File #, Page #, Option #);

DBCC TraceOn (3604);

-- PageFID = File Number, PagePID = Page NumberDBCC Page ('AdventureWorksDW2008R2', 1, 3458, 3) ;

Page 21: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Do as I Say, Not as I Do

Q&A

Page 22: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Do as I Say, Not as I Do

Thank You!The PowerPoint slide-deck will be available on my website:

http://www.sqlsoldier.com

Page 23: Do as I Say, Not as I Do Robert L Davis. Who am I? No one of consequence

Microsoft Certified Master