:VERSION 1         # -------------------------- 

BEGIN TRANSACTION

CREATE TABLE "GridUser" (
    "UserID" VARCHAR(255) NOT NULL,
    "HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
    "HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    "HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    "LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
    "LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    "LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    "Online" CHAR(5) NOT NULL DEFAULT 'false',
    "Login" CHAR(16) NOT NULL DEFAULT '0',
    "Logout" CHAR(16) NOT NULL DEFAULT '0',
    PRIMARY KEY  ("UserID")
) 

COMMIT

:VERSION 2         # -------------------------- 

BEGIN TRANSACTION

CREATE TABLE [GridUser_tmp] (
    [UserID] VARCHAR(255) NOT NULL,
    [HomeRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
    [HomePosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    [HomeLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    [LastRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
    [LastPosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    [LastLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
    [Online] CHAR(5) NOT NULL DEFAULT 'false',
    [Login] CHAR(16) NOT NULL DEFAULT '0',
    [Logout] CHAR(16) NOT NULL DEFAULT '0',
    
	  PRIMARY KEY CLUSTERED
		(
			[UserID] ASC
		)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
	) ON [PRIMARY]

COMMIT

IF EXISTS(SELECT * FROM dbo.GridUser)
	 EXEC('INSERT INTO dbo.GridUser_tmp ([UserID]
           ,[HomeRegionID]
           ,[HomePosition]
           ,[HomeLookAt]
           ,[LastRegionID]
           ,[LastPosition]
           ,[LastLookAt]
           ,[Online]
           ,[Login]
           ,[Logout])
		SELECT CONVERT(varchar(36), [HomeRegionID]), [HomePosition] ,[HomeLookAt] , CONVERT(varchar(36),[LastRegionID])
      ,[LastPosition]
      ,[LastLookAt]
      ,[Online]
      ,[Login]
      ,[Logout] FROM dbo.GridUser WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.GridUser

EXECUTE sp_rename N'dbo.GridUser_tmp', N'GridUser', 'OBJECT' 