Viewing 5 posts - 1 through 5 (of 5 total)
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
October 17, 2013 at 11:26 pm
--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,...
October 16, 2013 at 11:58 pm
/* 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...
September 21, 2011 at 3:44 am
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...
September 19, 2011 at 12:56 am
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...
September 18, 2011 at 11:52 pm
Viewing 5 posts - 1 through 5 (of 5 total)