MCITP

MCITP

Wednesday, October 9, 2013

Attach database

sp_attach_db [ @dbname= ] N'SharePoint2010_Config',
@filename1=N'G:\LDF\SharePoint2010_Config.mdf',
@filename2=N'G:\SharePoint2010_Config_log.LDF'
GO
 
 The sp_attach_db stored procedure should only be executed on databases that were previously detached from the database server by using an explicit sp_detach_db operation or on copied databases. If you have to specify more than 16 files, use CREATE DATABASE database_name FOR
ATTACH or CREATE DATABASE database_name FOR_ATTACH_REBUILD_LOG

When you attach a replicated database that was copied instead of being detached, consider the following:
•If you attach the database to the same server instance and version as the original database, no additional steps are required.
•If you attach the database to the same server instance but with an upgraded version, you must execute sp_vupgrade_replication to upgrade replication after the attach operation is complete.
•If you attach the database to a different server instance, regardless of version, you must execute sp_removedbreplication to remove replication after the attach operation is complete.
•The source database must be at least version 80 (SQL Server 2000) to attach to SQL Server 2008. SQL Server 2000 or SQL Server 2005 databases that have a compatibility level less than 80 will be set to compatibility 80 when attached.

Attach using create database command  =>
USE master;
GO
--Detach the AdventureWorks database
sp_detach_db AdventureWorks;
GO
-- Physically move the full text catalog to the new location.
--Attach the AdventureWorks database and specify the new location of the full-text catalog.
CREATE DATABASE AdventureWorks ON
    (FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_Data.mdf'),
    (FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf'),
    (FILENAME = 'c:\myFTCatalogs\AdvWksFtCat')
FOR ATTACH;
GO

To rebuild log file

USE [master]
GO
CREATE DATABASE [AdventureWorks] 
ON  PRIMARY ( NAME = N'AdventureWorks_Data',FILENAME = N'C:\SQLDBs\Data\RecoveryModelTesting_Data.mdf')
FOR ATTACH_REBUILD_LOG
GO

Tuesday, September 17, 2013

FTP command to exchange files between windows and hpux

E:\Script> ftp box.domain.co.uk

User (box.domain.co.uk:(none)): oracle
Password:

ftp>cd /home/test_script/script_original
pwd
257 "/home/test_script/script_original" is current directory.

ftp>help
Commands may be abbreviated.  Commands are:
!               delete          literal         prompt          send
?               debug           ls              put             status
append          dir             mdelete         pwd             trace
ascii           disconnect      mdir            quit            type
bell            get             mget            quote           user
binary          glob            mkdir           recv            verbose
bye             hash            mls             remotehelp
cd              help            mput            rename
close           lcd             open            rmdir

set to binary mode for transfering file to hpux from windows:
ftp>bi
200 Type set to I.
mput sa_readme.txt
mput sa_readme.txt? y

ftp>ascii
200 Type set to A.
mget sa_readme.txt
mput sa_readme.txt? y

ftp>bye