To install MSDE:
Better to stop IIS
Need "File and Printer sharing" and netBIOS over TCP/IP
Check "Administrative tools" -> "Local security policy"
"Security setting" -> "Local policies" -> "Security options"
"Unsigned non-driver installation behavior" => Allow

Modify setup.ini
SAPWD="xxxxxxx"
SECURITYMODE=SQL
DISABLENETWORKPROTOCOLS=0
TARGETDIR="c:\"

C:\MSDERelA>setup /settings setup.ini
Restart the PC
Security patch (SQL Server 2000 (32-bit) Security Patch MS03-031)
Detail: http://go.microsoft.com/fwlink/?LinkId=20286



How to copy MDF file
1. Copy mdf file to a location of choice
2. Open Enterprise Manager
3. Goto Tools -> SQL Query Analazyer
4. type in:
sp_attach_single_file_db @dbname=''
, @physname=''
You might need log file in same directory.


How to change the database owner
1. the SQL server->Security->Logins
2. dubble click the user name and Database Access tab
3. tick the database and db_owner (normally public should be clicked)
*4. If you cannot save, check the Owner of each tables and views and delete (or change owner)


Upgrade MSDE to SP4
C:\SQL2KSP4\MSDE>setup /upgradesp sqlrun
SEQURITYMODE=SQL UPGRADEUSER=SA ->
UPGRADEPWD=***** DISABLENETWORKPROTOCOLS=0 /L*v C:\MSDELog.log

Inserting NULL value is Ctrl + 0

Change owner
EXEC sp_changeobjectowner 'dbuser.mst_country', 'dbo'

Turn off message in Stored Procedure
SET NOCOUNT ON

Create temporary table
CREATE TABLE #Calendar (
BirthMonth INT PRIMARY KEY,
Employees NVARCHAR(100)
)

CURSOR for storing query result
DECLARE EmployeeBirthday CURSOR FOR
SELECT FirstName + LastName As EmployeeName, BirthDate
FROM Employees

WHILE Loop
SET @Counter = 1
WHILE @Counter < 13
BEGIN
INSERT INTO #Calendar ( BirthMonth, Employees )
VALUES ( @Counter, '' )
SET @Counter = @Counter + 1
END

Using CURSOR
OPEN EmployeeBirthday
FETCH NEXT FROM EmployeeBirthday INTO @EmployeeName, @BirthDate

WHILE @@FETCH_STATUS = 0
BEGIN
--- FETCH NEXT FROM EmployeeBirthday INTO @EmployeeName, @BirthDate
END
CLOSE EmployeeBirthday
DEALLOCATE EmployeeBirthday

Change transaction isolation level
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED