Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)

  • RE: Get last day of the month - 1

    Select dateadd(dd,-(day(getdate()))-1,getdate())

    or

    Select Dateadd(d,-DATEPART(d,DateAdd(m,1,dateadd(dd,-1,getdate())))-1,DateAdd(m,1,dateadd(dd,-1,getdate())))

    any query will get the lastdayofmonth-1

  • RE: Need a Query on group by condition

    --create a new local table and add start date column and separating the month and year in the monthyyear column

    Declare @loc_table table (emp int, dates int, year int,...

  • RE: how to store result of 1 sp into sp

    /* create table script*/

    CREATE TABLE [dbo].[Products]

    (

    [ProductID] [tinyint] IDENTITY(1,1) NOT NULL,

    [ProductName] [varchar](20) NULL,

    [RecommendedPrice] [money] NULL,

    [Category] [varchar](10) NULL,

    )

    /*creating the procedure*/

    Create procedure sp_get_products

    as

    BEGIn

    Select * from products

    END

    /*creating the variable and storing the sp related...

  • RE: Need Help with While loop please

    USE AdventureWorks2008R2

    GO

    DECLARE @inccount int

    SET @inccount = 1

    While ((SELECT COUNT(*) FROM Production.Product P RIGHT JOIN Production.ProductSubcategory SC

    ON SC.ProductSubcategoryID = P.ProductSubcategoryID

    JOIN Production.ProductCategory PC

    ON PC.ProductCategoryID = SC.ProductCategoryID

    WHERE PC.ProductCategoryID < 4)>=@inccount)

    BEGIN

    Declare @name varchar(100)

    ,@prodcatid...

  • RE: Please help me out this question?

    Declare @tab1 table

    (id int identity(1,1),name varchar(100),total int)

    Insert into @tab1

    Select ProductName,count(*)as Total from Products p join Sales s

    on p.ProductID = s.ProductID

    group by ProductName

    Declare @count int

    ,@incvalue int

    ,@out_msg varchar(10)

    Set @incvalue = 1

    Select @count...

Viewing 5 posts - 1 through 5 (of 5 total)