restore verifyonly from disk='e:\temp\fmuws_backup_201107070958.bak'
restore HEADERONLY from disk='e:\temp\fmuws_backup_201107070958.bak'
restore LABELONLY from disk='e:\temp\fmuws_backup_201107070958.bak'
restore FILELISTONLY from disk='e:\temp\fmuws_backup_201107070958.bak'
Friday, December 3, 2010
verify database backups in SQL Server 2005
RESTORE VERIFYONLY from disk ='D:\Backups\FormCenter\FormCenter_backup_201012022000.bak'
Wednesday, December 1, 2010
Check current database user and login user
execute as login = 'TFS4DBA' -------- server login
execute as user='afm' --------- database user
select current_user,SESSION_USER, USER ,system_user,SUSER_SNAME(),SUSER_SID()
execute as user='afm' --------- database user
select current_user,SESSION_USER, USER ,system_user,SUSER_SNAME(),SUSER_SID()
Monday, November 29, 2010
Change object owner in SQL Server 2005
EXEC sp_changeobjectowner 'web.rego_for_dism', 'dbo'
------
The following small SQL code snippet goes through all user tables in the database and changes their owner to dbo. It uses sp_changeobjectowner system stored procedure:
DECLARE tabcurs CURSOR
FOR
SELECT 'SOMEOWNER.' + [name]
FROM sysobjects
WHERE xtype = 'u'
OPEN tabcurs
DECLARE @tname NVARCHAR(517)
FETCH NEXT FROM tabcurs INTO @tname
WHILE @@fetch_status = 0
BEGIN
EXEC sp_changeobjectowner @tname, 'dbo'
FETCH NEXT FROM tabcurs INTO @tname
END
CLOSE tabcurs
DEALLOCATE tabcurs
------
The following small SQL code snippet goes through all user tables in the database and changes their owner to dbo. It uses sp_changeobjectowner system stored procedure:
DECLARE tabcurs CURSOR
FOR
SELECT 'SOMEOWNER.' + [name]
FROM sysobjects
WHERE xtype = 'u'
OPEN tabcurs
DECLARE @tname NVARCHAR(517)
FETCH NEXT FROM tabcurs INTO @tname
WHILE @@fetch_status = 0
BEGIN
EXEC sp_changeobjectowner @tname, 'dbo'
FETCH NEXT FROM tabcurs INTO @tname
END
CLOSE tabcurs
DEALLOCATE tabcurs
Subscribe to:
Posts (Atom)