Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.2 KiB

  1. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MSSolution]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
  2. drop table [dbo].[MSSolution]
  3. GO
  4. CREATE TABLE [dbo].[MSSolution] (
  5. [MSSolutionID] [int] NOT NULL ,
  6. [SolutionProvider] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  7. [SolutionText] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  8. [LastUpdated] [smalldatetime] NOT NULL
  9. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  10. GO
  11. ALTER TABLE [dbo].[MSSolution] WITH NOCHECK ADD
  12. CONSTRAINT [PK_MSSolution] PRIMARY KEY CLUSTERED
  13. (
  14. [MSSolutionID]
  15. ) ON [PRIMARY]
  16. GO
  17. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_BuildKBString]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  18. drop procedure [dbo].[SEP_BuildKBString]
  19. GO
  20. CREATE PROCEDURE SEP_BuildKBString( @Desc nvarchar(1024), @FinalKB nvarchar(100) OUTPUT ) AS
  21. --DECLARE @Desc nvarchar(1024)
  22. --select top 100 percent * from SolutionEx
  23. DECLARE @Counter int
  24. --DECLARE @FinalKB nvarchar(100)
  25. SET @Counter = 1
  26. SET @FinalKB = ''
  27. WHILE @Counter != LEN( @Desc )
  28. BEGIN
  29. IF( SUBSTRING( @Desc, @Counter, 4) = '<KB>' )
  30. BEGIN
  31. SET @Counter = @Counter + 4
  32. SET @FinalKB = @FinalKB + ' ' + SUBSTRING( @Desc, @Counter, 6 ) + CHAR(13) + CHAR(10)
  33. SET @Counter = @Counter + 11
  34. END
  35. ELSE
  36. BEGIN
  37. print 'no kb'
  38. BREAK
  39. END
  40. END
  41. GO
  42. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_BuildOEMSolutions]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  43. drop procedure [dbo].[SEP_BuildOEMSolutions]
  44. GO
  45. CREATE Procedure SEP_BuildOEMSolutions( ) as
  46. USE Solutions
  47. DECLARE @Desc nvarchar(1000)
  48. DECLARE @KBString nvarchar(1000)
  49. DECLARE @szTemplate nvarchar(4000)
  50. DECLARE @szModule nvarchar(100)
  51. DECLARE @szContact nvarchar(100)
  52. DECLARE @SolutionID INT
  53. DECLARE SolCursor CURSOR FOR
  54. select SolutionID from SolutionEx order by solutionID
  55. OPEN SolCursor
  56. FETCH NEXT FROM SolCursor INTO @SolutionID
  57. WHILE @@FETCH_STATUS = 0
  58. BEGIN
  59. IF NOT EXISTS ( SELECT MSSolutionID from MSSolution where MSSolutionID=@SolutionID )
  60. BEGIN
  61. SELECT @Desc = Description from SolutionEx where SolutionID = @SolutionID
  62. SELECT @szModule = ModuleName from Modules where ModuleID = (SELECT ModuleID from SolutionEX where SolutionID = @SolutionID )
  63. SELECT @szContact = CompanyName from Contacts where ContactID = (SELECT ContactID from SolutionEX where SolutionID = @SolutionID )
  64. SELECT @szTemplate = Description from templates where TemplateID = (SELECT TemplateID from SolutionEX where SolutionID = @SolutionID )
  65. SELECT @szTemplate = REPLACE ( @szTemplate, '<BR>', CHAR(13) )
  66. SELECT @szTemplate = REPLACE ( @szTemplate, '<CONTACT></CONTACT>', @szContact )
  67. SELECT @szTemplate = REPLACE ( @szTemplate, '<MODULE></MODULE>', @szModule )
  68. EXEC SEP_BuildKBString @Desc, @KBString OUTPUT
  69. SET @szTemplate = @szTemplate + CHAR(13) + 'KB Articles: ' + @KBString
  70. SELECT @szTemplate as newTEmplate, @SolutionID as SolutionID
  71. INSERT INTO MSSolution (MSSolutionID, SolutionProvider, SolutionText, LastUpdated ) VALUES
  72. ( @SolutionID, 'Microsoft', @szTemplate, GETDATE() )
  73. END
  74. FETCH NEXT FROM SolCursor INTO @SolutionID
  75. END
  76. CLOSE SolCursor
  77. DEALLOCATE SolCursor
  78. GO