Today we will discuss depricated features of SQL Server 2008. Let's list down the features, their usage and alternatives in SQL Server 2008.
sp_attach_db
Description: The sp_attach_db is a command to attach a database. This is one option for upgrading a database from SQL Server 2000 to 2005 or used in move databases from one SQL Server to another.
Syntax
EXEC sp_attach_db @dbname = 'YourDatabase',
@filename1 = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\YourDatabase.mdf',
@filename2 = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\YourDatabase_log.ldf'
GO
Change to CREATE DATABASE
Syntax
CREATE DATABASE database_name
ON
FOR { ATTACH [ WITH
| ATTACH_REBUILD_LOG } [;]
GO
The system stored procedure sp_detach_db according to SQL Server 2008 Books Online appears to remain the command to detach a database whereas sp_attach_db database is marked as deprecated.
sp_renamedb
Description: commonly used when servers are migrated or databases are moved.
Syntax
EXEC sp_renamedb '
GO
Change to ALTER DATABASE
ALTER DATABASE
Modify Name =
GO
sp_dboption
Description: commonly used for setting a database to read only or offline.
Syntax
USE master
EXEC sp_dboption 'YourDatabase', 'read only', 'TRUE'
GO
USE master
EXEC sp_dboption 'YourDatabase', 'offline', 'TRUE'
GO
Change to ALTER DATABASE
Syntax
ALTER DATABASE
SET READ_ONLY
GO
ALTER DATABASE
SET OFFLINE
GO
No comments:
Post a Comment