$proc = New-Object System.Diagnostics.Process $proc.StartInfo.FileName = "C:\Temporary\2014_SQLEXPRWT_x64_ENU.exe" $proc.StartInfo.Arguments = "/q /INDICATEPROGRESS /ACTION=Install /FEATURES=SQL,Tools /TCPENABLED=1 /INSTANCENAME=EXPRESS2014 /SQLSVCACCOUNT=`"NT AUTHORITY\Network Service`" /SQLSYSADMINACCOUNTS=`"BUILTIN\Administrators`" /AGTSVCACCOUNT=`"NT AUTHORITY\Network Service`" /SECURITYMODE=`"SQL`" /SAPWD=`"pwd123!123`" /IACCEPTSQLSERVERLICENSETERMS " write-host "Start Process" $proc.Start() $proc.WaitForExit()
create proc uspEvoBackup( @db varchar( 100)) as declare @path varchar(200) declare @cmd varchar( 500) set @path = 'D:\Temp\SqlDump\Schudel\' set @cmd = 'backup database ' + @db + ' to disk=''' + @path + @db + convert( varchar, getdate(), 112) + '_' + replace( convert( varchar, getdate(), 108), ':', '') + '.bak'' with init' exec( @cmd)
create procedure [dbo].[uspRefreshAllViews] AS declare @objectname varchar(300) declare objectCursor cursor local for select name FROM sysobjects WHERE type IN ('V') open objectCursor fetch next from objectCursor into @objectname while (@@fetch_status <> -1) begin exec sp_refreshview @objectname print @objectname exec( 'select count(*) from ' + @objectname + ' where 1=0') fetch next from objectCursor INTO @objectname end deallocate objectCursor
dbcc checkident ( tabellenname, reseed, 0)
SELECT @@Servername ServerName, SERVERPROPERTY('productversion') ProductVersion, SERVERPROPERTY ('productlevel') ProductLevel, SERVERPROPERTY ('edition') Edition
http://vyaskn.tripod.com/code/generate_inserts_2005.txt
select * into NeueTabelle from vwBestehendeView
if @@SERVERNAME <> 'ZIELSERVER' begin RAISERROR ('Dieses Skript darf nur auf dem ZIELSERVER verwendet werden.', 20, 1) with log end
select destination_database_name, MAX(restore_date) LastRestore from ( SELECT destination_database_name, [user_name] as 'Username', CASE restore_type WHEN NULL THEN 'NULL' WHEN 'D' THEN 'Database' WHEN 'F' THEN 'File' WHEN 'G' THEN 'Filegroup' WHEN 'I' THEN 'Differential' WHEN 'L' THEN 'Log File' WHEN 'V' THEN 'Verifyonly' WHEN 'R' THEN 'Revert' END as 'Restore Type', Case [replace] WHEN NULL THEN 'NULL' WHEN 1 THEN 'YES' WHEN 0 THEN 'NO' END as 'DatabaseReplaced', restore_date FROM msdb..restorehistory where destination_database_name in ( select name from sys.databases) ) D group by destination_database_name order by max(restore_date) desc