Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how to add int Value

how to add int Value

Scheduled Pinned Locked Moved Database
tutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    getaccessyr
    wrote on last edited by
    #1

    Create PROCEDURE [dbo].[WidgetServer_GetAllShopList_FR] ( @CatalogID nvarchar(max), @PageSize INT, @PageIndex INT, @NoOfPages INT OUTPUT ) AS DECLARE @StartRowIndex INT DECLARE @Delimiter CHAR DECLARE @iIndex SMALLINT DECLARE @iCatalogId INT DECLARE @iNoofPages INT -- DECLARE @CatalogID nvarchar(max) --DECLARE @PageSize INT --DECLARE @PageIndex INT --DECLARE @NoOfPages INT -- SET @CatalogID='1,2,3'; -- SET @PageIndex = 1; -- Set @PageSize = 5; SET NOCOUNT ON; SET @StartRowIndex= ((@PageIndex * @PageSize) + 1); BEGIN SET @Delimiter = ',' WHILE @CatalogID <> '' BEGIN SET @iIndex = CHARINDEX(@Delimiter, @CatalogID) IF @iIndex > 0 BEGIN SET @iCatalogId = LEFT(@CatalogID, @iIndex-1) SET @CatalogID = RIGHT(@CatalogID, LEN(@CatalogID) - @iIndex) END ELSE BEGIN SET @iCatalogId = @CatalogID SET @CatalogID = '' END BEGIN SET @iNoofPages = (SELECT ISNULL((SELECT ((COUNT(*) / @Pagesize) + CASE WHEN (COUNT(*) % @Pagesize) > 0 THEN 1 ELSE 0 END) FROM dbo.Shops INNER JOIN Folder ON Folder.ShopID = Shops.ShopID INNER JOIN [Catalog] ON Catalog.CatalogID = Folder.CatalogID WHERE Catalog.CatalogID = (@iCatalogId) AND dbo.Shops.[Status] = 1),0)); END SELECT Distinct Shops.ShopName_FR as ShopName, Shops.ShopID,Catalog.CatalogID, Catalog.CatalogName_FR as CatalogName, Folder.FolderName_FR as Folder FROM Catalog INNER JOIN Folder ON Catalog.CatalogID = Folder.CatalogID INNER JOIN Shops ON Folder.ShopID = Shops.ShopID Where Catalog.CatalogID = (@iCatalogId) END END In this while looping first we will get NoofPages=4 and then 2 I need to add those to values and get in NoofPages Can any one tell me how? Yamuna

    M 1 Reply Last reply
    0
    • G getaccessyr

      Create PROCEDURE [dbo].[WidgetServer_GetAllShopList_FR] ( @CatalogID nvarchar(max), @PageSize INT, @PageIndex INT, @NoOfPages INT OUTPUT ) AS DECLARE @StartRowIndex INT DECLARE @Delimiter CHAR DECLARE @iIndex SMALLINT DECLARE @iCatalogId INT DECLARE @iNoofPages INT -- DECLARE @CatalogID nvarchar(max) --DECLARE @PageSize INT --DECLARE @PageIndex INT --DECLARE @NoOfPages INT -- SET @CatalogID='1,2,3'; -- SET @PageIndex = 1; -- Set @PageSize = 5; SET NOCOUNT ON; SET @StartRowIndex= ((@PageIndex * @PageSize) + 1); BEGIN SET @Delimiter = ',' WHILE @CatalogID <> '' BEGIN SET @iIndex = CHARINDEX(@Delimiter, @CatalogID) IF @iIndex > 0 BEGIN SET @iCatalogId = LEFT(@CatalogID, @iIndex-1) SET @CatalogID = RIGHT(@CatalogID, LEN(@CatalogID) - @iIndex) END ELSE BEGIN SET @iCatalogId = @CatalogID SET @CatalogID = '' END BEGIN SET @iNoofPages = (SELECT ISNULL((SELECT ((COUNT(*) / @Pagesize) + CASE WHEN (COUNT(*) % @Pagesize) > 0 THEN 1 ELSE 0 END) FROM dbo.Shops INNER JOIN Folder ON Folder.ShopID = Shops.ShopID INNER JOIN [Catalog] ON Catalog.CatalogID = Folder.CatalogID WHERE Catalog.CatalogID = (@iCatalogId) AND dbo.Shops.[Status] = 1),0)); END SELECT Distinct Shops.ShopName_FR as ShopName, Shops.ShopID,Catalog.CatalogID, Catalog.CatalogName_FR as CatalogName, Folder.FolderName_FR as Folder FROM Catalog INNER JOIN Folder ON Catalog.CatalogID = Folder.CatalogID INNER JOIN Shops ON Folder.ShopID = Shops.ShopID Where Catalog.CatalogID = (@iCatalogId) END END In this while looping first we will get NoofPages=4 and then 2 I need to add those to values and get in NoofPages Can any one tell me how? Yamuna

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      PLEASE use

      tags when posting your code.

      Are you trying to get the sum of noofpages?

      Declare
      @Var INT

      Select @Var = SUM(case statement)
      From ....

      Print '@Var ' + Convert(varchar(1000),@Var)

      G 1 Reply Last reply
      0
      • M Mycroft Holmes

        PLEASE use

        tags when posting your code.

        Are you trying to get the sum of noofpages?

        Declare
        @Var INT

        Select @Var = SUM(case statement)
        From ....

        Print '@Var ' + Convert(varchar(1000),@Var)

        G Offline
        G Offline
        getaccessyr
        wrote on last edited by
        #3

        hi Thanks for your reply how can we get the NoofPages count here thru when case? explain in detail. regards, Yamuna

        M 1 Reply Last reply
        0
        • G getaccessyr

          hi Thanks for your reply how can we get the NoofPages count here thru when case? explain in detail. regards, Yamuna

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          yamunarani wrote:

          explain in detail.

          The new snd codz plz Sorry if you cannot work it out then I can't help you.

          Never underestimate the power of human stupidity RAH

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups