Tuesday, December 13, 2011

Move a database path during a restore!!

SQL Dba's are you moving databases between PROD and DEV. They have different file structures right? Well try using the MOVE command with your restore. It will save time and effort.
restore database BuildingDepartment from disk =
'G:\backup\BuildingDepartment_backup_201112080500.bak'
with recovery,
MOVE 'BuildingDepartment' TO 'G:\Data\BuildingDepartment.mdf',
MOVE 'BuildingDepartment_Log' TO 'G:\Logs\BuildingDepartment.ldf'
go

Monday, December 12, 2011

Database diagram support objects can not be installed?

First make sure that there is a valid owner for the database. I.E. make sure owner is not blank.
If that doesnt fix your problem then try this command on the new query line.
ALTER AUTHORIZATION ON DATABASE::database_name TO valid_login

Friday, October 28, 2011

Version error while executing SSIS package

To clarify a bit more, packages created in Visual Studio 2008 are SQL Server 2008 packages. If you have both 2005 and 2008 installed on your system, you'll need to provide the explicit path to the 2008 version of DTEXEC when you run the package:

Tuesday, October 25, 2011

MS SQL 2008 DTS package error

Description: The version number in the package is not valid. The version number cannot be greater than current version number.
you'll need to provide the explicit path to the 2008 version of DTEXEC when you run the package:

How to setup the PREREQS for oracle databases

ALter database test
Set READ_COMMITTED_SNAPSHOT = ON
go
Alter database test
Set ALLOW_SNAPSHOT_ISOLATION = ON
go

Select the SQL Server authentication option
when you set the security
properties for the database.
go
>>The schema owner for the above repositories will require DB_OWNER and
>>BULK_INSERT.
>>
>>Run the collate script on the repositories:

>>DECLARE @collate sysname
>>SELECT @collate = convert(sysname, serverproperty('COLLATION'))
>>IF ( charindex(N'_CI', @collate) > 0 )
>>BEGIN
>>select @collate = replace(@collate, N'_CI', N'_CS')
>>exec ('ALTER database OBIAPP COLLATE ' + @collate)
>>END
>>GO

How to reindex all tables in a database

Let assume that the database is named clo
USE clo
GO
EXEC sp_MSforeachtable @command1="print '?' DBCC DBREINDEX ('?', ' ', 80)"
GO
EXEC sp_updatestats
GO

Monday, October 24, 2011

Find failed SQL jobs in one click

--The code to convert run_date and run_time into an actual--datetime is NOT my code, and I can't remember what blog post--I found it from. But it's not mine.select sj.name, sjs.step_name,CONVERT ( DATETIME, RTRIM(run_date))+(run_time * 9+ run_time % 10000 * 6 + run_time % 100 * 10) / 216e4from msdb.dbo.sysjobs sjinner join msdb.dbo.sysjobsteps sjson sj.job_id = sjs.job_idinner join msdb.dbo.sysjobhistory sjhon sjs.job_id = sjh.job_idand sjs.step_id = sjh.step_idwhere sjh.run_status = 0and datediff (hour, (CONVERT ( DATETIME, RTRIM(run_date))+(run_time * 9+ run_time % 10000 * 6 + run_time % 100 * 10) / 216e4), current_timestamp) <= 24