Setup: Difference between revisions

From Customer365 for SageCRM
(Created page with "The visitor table should be updated to cater for longer values than is has. We do this using the following SQL. Create a new table based on the visitor table but with larger ...")
 
No edit summary
Line 4: Line 4:
Create a new table based on the visitor table but with larger size columns
Create a new table based on the visitor table but with larger size columns


   CREATE TABLE [dbo].[visitor_new](
   CREATE TABLE [dbo].[visitor_new]( [Visi_VisitorId] [int] IDENTITY(1,1) NOT NULL,
[Visi_VisitorId] [int] IDENTITY(1,1) NOT NULL,
[Visi_VisitorKey] [nvarchar](50) NULL,
[Visi_VisitorKey] [nvarchar](50) NULL,
[Visi_LogonId] [nvarchar](200) NULL,
[Visi_LogonId] [nvarchar](200) NULL,

Revision as of 16:14, 5 August 2014

The visitor table should be updated to cater for longer values than is has. We do this using the following SQL.

Create a new table based on the visitor table but with larger size columns

 CREATE TABLE [dbo].[visitor_new](	[Visi_VisitorId] [int] IDENTITY(1,1) NOT NULL,

[Visi_VisitorKey] [nvarchar](50) NULL, [Visi_LogonId] [nvarchar](200) NULL, [Visi_Password] [nvarchar](12) NULL, [Visi_PersonId] [int] NULL, [Visi_CompanyId] [int] NULL, [Visi_IpAddress] [nvarchar](15) NULL, [Visi_Salutation] [nvarchar](10) NULL, [Visi_FirstName] [nvarchar](30) NULL, [Visi_LastName] [nvarchar](40) NULL, [Visi_MiddleName] [nvarchar](30) NULL, [Visi_Suffix] [nvarchar](20) NULL, [Visi_Gender] [nvarchar](6) NULL, [Visi_Title] [nvarchar](30) NULL, [Visi_TitleCode] [nvarchar](15) NULL, [Visi_CompanyName] [nvarchar](60) NULL, [Visi_PhoneCountryCode] [nvarchar](5) NULL, [Visi_PhoneAreaCode] [nvarchar](20) NULL, [Visi_PhoneNumber] [nvarchar](200) NULL, [Visi_FaxCountryCode] [nvarchar](5) NULL, [Visi_FaxAreaCode] [nvarchar](20) NULL, [Visi_FaxNumber] [nvarchar](20) NULL, [Visi_EmailAddress] [nvarchar](200) NULL, [Visi_Address1] [nvarchar](40) NULL, [Visi_Address2] [nvarchar](40) NULL, [Visi_Address3] [nvarchar](40) NULL, [Visi_Address4] [nvarchar](40) NULL, [Visi_Address5] [nvarchar](40) NULL, [Visi_City] [nvarchar](30) NULL, [Visi_State] [nvarchar](30) NULL, [Visi_Country] [nvarchar](30) NULL, [Visi_PostCode] [nvarchar](10) NULL, [Visi_Language] [nvarchar](5) NULL, [Visi_CreatedDate] [datetime] NULL, [Visi_UpdatedDate] [datetime] NULL, [visi_userid] [int] NULL

 ) ON [PRIMARY]

We then run the following to populate the table based on the visitor table (assuming self-service is already in use)

 SET IDENTITY_INSERT visitor_new on
 GO
 INSERT INTO visitor_new (
 [Visi_VisitorId] ,

[Visi_VisitorKey] , [Visi_LogonId], [Visi_Password] , [Visi_PersonId], [Visi_CompanyId] , [Visi_IpAddress] , [Visi_Salutation] , [Visi_FirstName] , [Visi_LastName] , [Visi_MiddleName], [Visi_Suffix], [Visi_Gender] , [Visi_Title] , [Visi_TitleCode], [Visi_CompanyName], [Visi_PhoneCountryCode], [Visi_PhoneAreaCode] , [Visi_PhoneNumber], [Visi_FaxCountryCode] , [Visi_FaxAreaCode] , [Visi_FaxNumber] , [Visi_EmailAddress], [Visi_Address1] , [Visi_Address2], [Visi_Address3] , [Visi_Address4], [Visi_Address5] , [Visi_City] , [Visi_State] , [Visi_Country], [Visi_PostCode], [Visi_Language] , [Visi_CreatedDate], [Visi_UpdatedDate] , [visi_userid]

 )
 SELECT 
 [Visi_VisitorId] ,

[Visi_VisitorKey] , [Visi_LogonId], [Visi_Password] , [Visi_PersonId], [Visi_CompanyId] , [Visi_IpAddress] , [Visi_Salutation] , [Visi_FirstName] , [Visi_LastName] , [Visi_MiddleName], [Visi_Suffix], [Visi_Gender] , [Visi_Title] , [Visi_TitleCode], [Visi_CompanyName], [Visi_PhoneCountryCode], [Visi_PhoneAreaCode] , [Visi_PhoneNumber], [Visi_FaxCountryCode] , [Visi_FaxAreaCode] , [Visi_FaxNumber] , [Visi_EmailAddress], [Visi_Address1] , [Visi_Address2], [Visi_Address3] , [Visi_Address4], [Visi_Address5] , [Visi_City] , [Visi_State] , [Visi_Country], [Visi_PostCode], [Visi_Language] , [Visi_CreatedDate], [Visi_UpdatedDate] , [visi_userid]

 from visitor
 GO
 SET IDENTITY_INSERT visitor_new Off

Rename the "visitor" table to "visitor_old" and then rename "vistor_new" to "visitor".