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.

750 lines
16 KiB

  1. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DBGPortal_GetCommentActions]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  2. drop procedure [dbo].[DBGPortal_GetCommentActions]
  3. GO
  4. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetAllSolutionData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  5. drop procedure [dbo].[SEP_GetAllSolutionData]
  6. GO
  7. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetContact]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  8. drop procedure [dbo].[SEP_GetContact]
  9. GO
  10. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetContacts]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  11. drop procedure [dbo].[SEP_GetContacts]
  12. GO
  13. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetDeliveryTypeBySolutionType]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  14. drop procedure [dbo].[SEP_GetDeliveryTypeBySolutionType]
  15. GO
  16. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetModuleData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  17. drop procedure [dbo].[SEP_GetModuleData]
  18. GO
  19. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetModules]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  20. drop procedure [dbo].[SEP_GetModules]
  21. GO
  22. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetProductData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  23. drop procedure [dbo].[SEP_GetProductData]
  24. GO
  25. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetProducts]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  26. drop procedure [dbo].[SEP_GetProducts]
  27. GO
  28. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetSolutionBySolutionID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  29. drop procedure [dbo].[SEP_GetSolutionBySolutionID]
  30. GO
  31. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetSolutionData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  32. drop procedure [dbo].[SEP_GetSolutionData]
  33. GO
  34. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetSolutionIDs]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  35. drop procedure [dbo].[SEP_GetSolutionIDs]
  36. GO
  37. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetSolutionTypes]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  38. drop procedure [dbo].[SEP_GetSolutionTypes]
  39. GO
  40. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetSolvedBucketsbySolutionID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  41. drop procedure [dbo].[SEP_GetSolvedBucketsbySolutionID]
  42. GO
  43. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetTemplateData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  44. drop procedure [dbo].[SEP_GetTemplateData]
  45. GO
  46. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetTemplates]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  47. drop procedure [dbo].[SEP_GetTemplates]
  48. GO
  49. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_GetiBucketValueByBucketID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  50. drop procedure [dbo].[SEP_GetiBucketValueByBucketID]
  51. GO
  52. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_SetContact]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  53. drop procedure [dbo].[SEP_SetContact]
  54. GO
  55. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_SetModuleData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  56. drop procedure [dbo].[SEP_SetModuleData]
  57. GO
  58. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_SetProductData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  59. drop procedure [dbo].[SEP_SetProductData]
  60. GO
  61. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_SetSolutionData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  62. drop procedure [dbo].[SEP_SetSolutionData]
  63. GO
  64. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SEP_SetTemplateData]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
  65. drop procedure [dbo].[SEP_SetTemplateData]
  66. GO
  67. SET QUOTED_IDENTIFIER OFF
  68. GO
  69. SET ANSI_NULLS OFF
  70. GO
  71. CREATE PROCEDURE DBGPortal_GetCommentActions AS
  72. SELECT * FROM crashdb3.dbo.CommentActions WHERE ActionID <= 5
  73. GO
  74. SET QUOTED_IDENTIFIER OFF
  75. GO
  76. SET ANSI_NULLS ON
  77. GO
  78. SET QUOTED_IDENTIFIER ON
  79. GO
  80. SET ANSI_NULLS OFF
  81. GO
  82. CREATE PROCEDURE SEP_GetAllSolutionData (
  83. @solutionID int = 0,
  84. @CrashType tinyint = 0
  85. ) AS
  86. IF ( @SolutionID = 0 )
  87. BEGIN
  88. IF ( @CrashType = 1 )
  89. BEGIN
  90. select SolutionID, Lang, SolutionTypeName, ModuleName, TemplateName, ProductName, CompanyName, BugID from Solutionex as SX
  91. left join SolutionTypes on SolutionType = SolutionTypeID
  92. left join Templates as T on sx.TemplateID = T.TemplateID
  93. left join Products as P on sx.ProductID = P.ProductID
  94. left join Contacts as C on sx.ContactID = C.ContactID
  95. left join Modules as M on sx.ModuleID = M.ModuleID
  96. where SX.CrashType = 1
  97. END
  98. ELSE
  99. BEGIN
  100. select SolutionID, Lang, SolutionTypeName, ModuleName, TemplateName, ProductName, CompanyName, BugID from Solutionex as SX
  101. left join SolutionTypes on SolutionType = SolutionTypeID
  102. left join Templates as T on sx.TemplateID = T.TemplateID
  103. left join Products as P on sx.ProductID = P.ProductID
  104. left join Contacts as C on sx.ContactID = C.ContactID
  105. left join Modules as M on sx.ModuleID = M.ModuleID
  106. where SX.CrashType <> 1
  107. END
  108. END
  109. ELSE
  110. BEGIN
  111. select SolutionID, Lang, SolutionTypeName, ModuleName, TemplateName, ProductName, CompanyName, BugID from Solutionex as SX
  112. left join SolutionTypes on SolutionType = SolutionTypeID
  113. left join Templates as T on sx.TemplateID = T.TemplateID
  114. left join Products as P on sx.ProductID = P.ProductID
  115. left join Contacts as C on sx.ContactID = C.ContactID
  116. left join Modules as M on sx.ModuleID = M.ModuleID
  117. WHERE SolutionID = @SolutionID
  118. END
  119. GO
  120. SET QUOTED_IDENTIFIER OFF
  121. GO
  122. SET ANSI_NULLS ON
  123. GO
  124. SET QUOTED_IDENTIFIER OFF
  125. GO
  126. SET ANSI_NULLS OFF
  127. GO
  128. CREATE PROCEDURE SEP_GetContact(
  129. @ContactID int
  130. )
  131. AS
  132. SELECT * FROM Contacts WHERE ContactID = @ContactID
  133. GO
  134. SET QUOTED_IDENTIFIER OFF
  135. GO
  136. SET ANSI_NULLS ON
  137. GO
  138. SET QUOTED_IDENTIFIER ON
  139. GO
  140. SET ANSI_NULLS ON
  141. GO
  142. CREATE PROCEDURE SEP_GetContacts
  143. AS
  144. SELECT ContactID, CompanyName FROM Contacts ORDER BY CompanyName
  145. GO
  146. SET QUOTED_IDENTIFIER OFF
  147. GO
  148. SET ANSI_NULLS ON
  149. GO
  150. SET QUOTED_IDENTIFIER ON
  151. GO
  152. SET ANSI_NULLS OFF
  153. GO
  154. CREATE PROCEDURE SEP_GetDeliveryTypeBySolutionType (
  155. @SolutionTypeID int
  156. ) AS
  157. SELECT DeliveryTypeID, DeliveryType FROM DeliveryTypeMap as M
  158. inner join DeliveryTypes as D on D.DeliveryID = M.DeliveryTypeID
  159. WHERE SolutionTypeID = @SolutionTypeID
  160. GO
  161. SET QUOTED_IDENTIFIER OFF
  162. GO
  163. SET ANSI_NULLS ON
  164. GO
  165. SET QUOTED_IDENTIFIER ON
  166. GO
  167. SET ANSI_NULLS OFF
  168. GO
  169. CREATE PROCEDURE SEP_GetModuleData (
  170. @ModuleID int
  171. ) AS
  172. SELECT ModuleName FROM Modules WHERE ModuleID = @ModuleID
  173. GO
  174. SET QUOTED_IDENTIFIER OFF
  175. GO
  176. SET ANSI_NULLS ON
  177. GO
  178. SET QUOTED_IDENTIFIER ON
  179. GO
  180. SET ANSI_NULLS ON
  181. GO
  182. CREATE PROCEDURE SEP_GetModules
  183. AS
  184. SELECT ModuleID, ModuleName FROM Modules ORDER BY ModuleName
  185. GO
  186. SET QUOTED_IDENTIFIER OFF
  187. GO
  188. SET ANSI_NULLS ON
  189. GO
  190. SET QUOTED_IDENTIFIER ON
  191. GO
  192. SET ANSI_NULLS OFF
  193. GO
  194. CREATE PROCEDURE SEP_GetProductData (
  195. @ProductID int
  196. ) AS
  197. SELECT ProductName FROM Products WHERE ProductID = @ProductID order by productName
  198. GO
  199. SET QUOTED_IDENTIFIER OFF
  200. GO
  201. SET ANSI_NULLS ON
  202. GO
  203. SET QUOTED_IDENTIFIER ON
  204. GO
  205. SET ANSI_NULLS ON
  206. GO
  207. CREATE PROCEDURE SEP_GetProducts
  208. AS
  209. SELECT ProductID, ProductName FROM Products ORDER BY ProductName
  210. GO
  211. SET QUOTED_IDENTIFIER OFF
  212. GO
  213. SET ANSI_NULLS ON
  214. GO
  215. SET QUOTED_IDENTIFIER OFF
  216. GO
  217. SET ANSI_NULLS OFF
  218. GO
  219. CREATE PROCEDURE SEP_GetSolutionBySolutionID(
  220. @SolutionID int
  221. ) AS
  222. SELECT * from SolutionEx where SolutionID = @SolutionID
  223. GO
  224. SET QUOTED_IDENTIFIER OFF
  225. GO
  226. SET ANSI_NULLS ON
  227. GO
  228. SET QUOTED_IDENTIFIER ON
  229. GO
  230. SET ANSI_NULLS OFF
  231. GO
  232. CREATE PROCEDURE SEP_GetSolutionData(
  233. @TemplateID int,
  234. @ContactID int,
  235. @ProductID int,
  236. @ModuleID int,
  237. @Language nvarchar(4) = 'en'
  238. ) AS
  239. IF ( @Language <> 'en' )
  240. BEGIN
  241. IF NOT EXISTS (
  242. SELECT * FROM Templates where TemplateID = @TemplateID and Lang = @Language
  243. )
  244. SET @Language = 'en'
  245. END
  246. select
  247. (select ProductName from Products where ProductID=@ProductID) as ProductName ,
  248. (Select ModuleName from Modules where ModuleID = @ModuleID) as ModuleName,
  249. (Select CompanyName from Contacts where ContactID = @ContactID) as CompanyName,
  250. (Select CompanyMainPhone from Contacts where ContactID = @ContactID) as CompanyMainPhone,
  251. (Select CompanyWebSite from Contacts where ContactID = @ContactID) as CompanyWebsite,
  252. [Description]
  253. from Templates
  254. where TemplateID = @TemplateID and Lang=@Language
  255. GO
  256. SET QUOTED_IDENTIFIER OFF
  257. GO
  258. SET ANSI_NULLS ON
  259. GO
  260. SET QUOTED_IDENTIFIER OFF
  261. GO
  262. SET ANSI_NULLS OFF
  263. GO
  264. CREATE PROCEDURE SEP_GetSolutionIDs
  265. AS
  266. SELECT SolutionID, SolutionID FROM SolutionEx ORDER BY SolutionID
  267. GO
  268. SET QUOTED_IDENTIFIER OFF
  269. GO
  270. SET ANSI_NULLS ON
  271. GO
  272. SET QUOTED_IDENTIFIER OFF
  273. GO
  274. SET ANSI_NULLS OFF
  275. GO
  276. CREATE PROCEDURE SEP_GetSolutionTypes
  277. AS
  278. SELECT SolutionTypeID, SolutionTypeName FROM SolutionTypes ORDER BY SolutionTypeID
  279. GO
  280. SET QUOTED_IDENTIFIER OFF
  281. GO
  282. SET ANSI_NULLS ON
  283. GO
  284. SET QUOTED_IDENTIFIER OFF
  285. GO
  286. SET ANSI_NULLS OFF
  287. GO
  288. CREATE PROCEDURE dbo.SEP_GetSolvedBucketsbySolutionID(
  289. @SolutionID int
  290. ) AS
  291. SELECT
  292. BucketID,
  293. SolutionID,
  294. SolutionType
  295. FROM
  296. SolvedBuckets
  297. WHERE
  298. SolutionID = @SolutionID
  299. GO
  300. SET QUOTED_IDENTIFIER OFF
  301. GO
  302. SET ANSI_NULLS ON
  303. GO
  304. SET QUOTED_IDENTIFIER OFF
  305. GO
  306. SET ANSI_NULLS OFF
  307. GO
  308. CREATE PROCEDURE SEP_GetTemplateData (
  309. @TemplateID int
  310. ) AS
  311. SELECT Lang, TemplateName, [Description] FROM Templates WHERE TemplateID = @TemplateID
  312. GO
  313. SET QUOTED_IDENTIFIER OFF
  314. GO
  315. SET ANSI_NULLS ON
  316. GO
  317. SET QUOTED_IDENTIFIER OFF
  318. GO
  319. SET ANSI_NULLS OFF
  320. GO
  321. CREATE PROCEDURE SEP_GetTemplates
  322. AS
  323. SELECT TemplateID, TemplateName FROM Templates where lang='en' ORDER BY TemplateName
  324. GO
  325. SET QUOTED_IDENTIFIER OFF
  326. GO
  327. SET ANSI_NULLS ON
  328. GO
  329. SET QUOTED_IDENTIFIER ON
  330. GO
  331. SET ANSI_NULLS OFF
  332. GO
  333. CREATE PROCEDURE dbo.SEP_GetiBucketValueByBucketID(
  334. @BucketID varchar(100)
  335. ) AS
  336. SELECT iBucket from CrashDB2.dbo.BucketToInt where BucketID = @BucketID
  337. GO
  338. SET QUOTED_IDENTIFIER OFF
  339. GO
  340. SET ANSI_NULLS ON
  341. GO
  342. SET QUOTED_IDENTIFIER ON
  343. GO
  344. SET ANSI_NULLS OFF
  345. GO
  346. CREATE PROCEDURE SEP_SetContact (
  347. @ContactID int,
  348. @CompanyName nvarchar(128),
  349. @CompanyAddress1 nvarchar(64),
  350. @CompanyAddress2 nvarchar(64),
  351. @CompanyCity nvarchar(16),
  352. @CompanyState nvarchar(4),
  353. @CompanyZip nvarchar(16),
  354. @CompanyMainPhone nvarchar(16),
  355. @CompanySupportPhone nvarchar(16),
  356. @CompanyFax nvarchar(16),
  357. @CompanyWebSite nvarchar(128),
  358. @ContactName nvarchar(32),
  359. @ContactOccupation nvarchar(32),
  360. @ContactAddress1 nvarchar(64),
  361. @ContactAddress2 nvarchar(64),
  362. @ContactCity nvarchar(16),
  363. @ContactState nvarchar(4),
  364. @ContactZip nvarchar(16),
  365. @ContactPhone nvarchar(16),
  366. @ContactEMail nvarchar(64)
  367. ) AS
  368. IF EXISTS(SELECT * FROM Contacts WHERE ContactID = @ContactID)
  369. BEGIN
  370. UPDATE Contacts SET
  371. CompanyName = @CompanyName,
  372. CompanyAddress1 = @CompanyAddress1,
  373. CompanyAddress2 = @CompanyAddress2,
  374. CompanyCity = @CompanyCity,
  375. CompanyState = @CompanyState,
  376. CompanyZip = @CompanyZip,
  377. CompanyMainPhone = @CompanyMainPhone,
  378. CompanySupportPhone = @CompanySupportPhone,
  379. CompanyFax = @CompanyFax,
  380. CompanyWebSite = @CompanyWebSite,
  381. ContactName = @ContactName,
  382. ContactOccupation = @ContactOccupation,
  383. ContactAddress1 = @contactAddress1,
  384. ContactAddress2 = @ContactAddress2,
  385. ContactCity = @ContactCity,
  386. ContactState = @ContactState,
  387. ContactZip = @ContactZip,
  388. ContactPhone = @ContactPhone,
  389. ContactEMail = @ContactEMail
  390. WHERE
  391. ContactID = @ContactID
  392. SELECT @ContactID as ContactID
  393. END
  394. ELSE
  395. BEGIN
  396. INSERT INTO Contacts
  397. (CompanyName, CompanyAddress1, CompanyAddress2, CompanyCity, CompanyState, CompanyZip,
  398. CompanyMainPhone, CompanySupportPhone, CompanyFax, CompanyWebSite,
  399. ContactName, ContactOccupation, ContactAddress1, ContactAddress2, ContactCity, ContactState, ContactZip,
  400. ContactPhone, ContactEMail)
  401. VALUES
  402. (@CompanyName, @CompanyAddress1, @CompanyAddress2, @CompanyCity, @CompanyState, @CompanyZip,
  403. @CompanyMainPhone, @CompanySupportPhone, @CompanyFax, @CompanyWebSite,
  404. @ContactName, @ContactOccupation, @ContactAddress1, @ContactAddress2, @ContactCity, @ContactState, @ContactZip,
  405. @ContactPhone, @ContactEMail)
  406. SELECT @@Identity as ContactID
  407. END
  408. GO
  409. SET QUOTED_IDENTIFIER OFF
  410. GO
  411. SET ANSI_NULLS ON
  412. GO
  413. SET QUOTED_IDENTIFIER ON
  414. GO
  415. SET ANSI_NULLS OFF
  416. GO
  417. CREATE PROCEDURE SEP_SetModuleData (
  418. @ModuleID int,
  419. @ModuleName nvarchar(128)
  420. ) AS
  421. IF EXISTS (SELECT * FROM Modules WHERE ModuleID = @ModuleID)
  422. BEGIN
  423. UPDATE Modules SET
  424. ModuleName = @ModuleName
  425. WHERE
  426. ModuleID = @ModuleID
  427. SELECT @ModuleID as ModuleID
  428. END
  429. ELSE
  430. BEGIN
  431. INSERT INTO Modules
  432. (ModuleName)
  433. VALUES
  434. (@ModuleName)
  435. SELECT @@IDENTITY AS ModuleID
  436. END
  437. GO
  438. SET QUOTED_IDENTIFIER OFF
  439. GO
  440. SET ANSI_NULLS ON
  441. GO
  442. SET QUOTED_IDENTIFIER ON
  443. GO
  444. SET ANSI_NULLS OFF
  445. GO
  446. CREATE PROCEDURE SEP_SetProductData (
  447. @ProductID int,
  448. @ProductName nvarchar(128)
  449. ) AS
  450. IF EXISTS (SELECT * FROM Products WHERE ProductID = @ProductID)
  451. BEGIN
  452. UPDATE Products SET
  453. ProductName = @ProductName
  454. WHERE
  455. ProductID = @ProductID
  456. SELECT @ProductID as ProductID
  457. END
  458. ELSE
  459. BEGIN
  460. INSERT INTO Products
  461. (ProductName)
  462. VALUES
  463. (@ProductName)
  464. SELECT @@IDENTITY AS ProductID
  465. END
  466. GO
  467. SET QUOTED_IDENTIFIER OFF
  468. GO
  469. SET ANSI_NULLS ON
  470. GO
  471. SET QUOTED_IDENTIFIER OFF
  472. GO
  473. SET ANSI_NULLS OFF
  474. GO
  475. CREATE PROCEDURE SEP_SetSolutionData(
  476. @SolutionID int,
  477. @SolutionType tinyint,
  478. @DeliveryType tinyint,
  479. @SP tinyint = 0,
  480. @TemplateID int,
  481. @ProductID int,
  482. @Description nvarchar(1024),
  483. @ContactID int,
  484. @ModuleID int,
  485. @UserMode tinyint = 0
  486. ) AS
  487. IF ( @SolutionID = 0 )
  488. SELECT @SolutionID = MAX(SolutionID) + 1 FROM SolutionEX
  489. IF EXISTS (SELECT * FROM SolutionEx WHERE SolutionID = @SolutionID)
  490. UPDATE SolutionEx SET
  491. SolutionType = @SolutionType,
  492. DeliveryType = @DeliveryType,
  493. SP = @SP,
  494. TemplateID = @TemplateID,
  495. ProductID = @ProductID,
  496. [Description] = @Description,
  497. ContactID = @ContactID,
  498. ModuleID = @ModuleID
  499. WHERE
  500. SolutionID = @SolutionID
  501. ELSE
  502. INSERT INTO SolutionEx
  503. (SolutionID, SolutionType, DeliveryType, SP, TemplateID, ProductID, [Description], ContactID, ModuleID )
  504. VALUES
  505. (@SolutionID, @SolutionType, @DeliveryType, @SP, @TemplateID, @ProductID, @Description, @ContactID, @ModuleID )
  506. SELECT @SolutionID as SolutionID
  507. GO
  508. SET QUOTED_IDENTIFIER OFF
  509. GO
  510. SET ANSI_NULLS ON
  511. GO
  512. SET QUOTED_IDENTIFIER OFF
  513. GO
  514. SET ANSI_NULLS OFF
  515. GO
  516. CREATE PROCEDURE SEP_SetTemplateData (
  517. @TemplateID int,
  518. @TemplateName nvarchar(32),
  519. @Description ntext,
  520. @Lang varchar(5) = 'en'
  521. ) AS
  522. DECLARE @NewID int
  523. IF EXISTS (SELECT * FROM Templates WHERE TemplateID = @TemplateID )
  524. BEGIN
  525. IF EXISTS( SELECT * FROM Templates where TemplateID = @TemplateID and Lang = @Lang )
  526. UPDATE Templates SET
  527. TemplateName = @TemplateName,
  528. Description = @Description
  529. WHERE
  530. TemplateID = @TemplateID and Lang = @Lang
  531. ELSE
  532. INSERT INTO Templates
  533. (TemplateName, Description, Lang, TemplateID )
  534. VALUES
  535. (@TemplateName, @Description, @Lang, @TemplateID )
  536. END
  537. ELSE
  538. BEGIN
  539. SELECT @NewID = MAX(TemplateID)+1 from Templates
  540. INSERT INTO Templates
  541. (TemplateName, Description, Lang, TemplateID )
  542. VALUES
  543. (@TemplateName, @Description, @Lang, @NewID )
  544. SELECT @NewID as TemplateID
  545. END
  546. GO
  547. SET QUOTED_IDENTIFIER OFF
  548. GO
  549. SET ANSI_NULLS ON
  550. GO