DECLARE @today DATE = GETDATE();
SELECT FORMAT(@today, 'yyyy-MM-dd', 'fa-IR') AS PersianDate;
declare @date as int
declare @day as int
declare @month as int
set @date=14030101
set @day=1
set @month=1
create table #tblDate (
[dt] int,
[myDay] int
);
while (@month<=12)
begin
insert into #tblDate (dt, myDay) values (@date, @day)
set @day = @day + 1
if (@month<7) and (@day>31)
begin
set @day= 1
set @month = @month + 1
set @date = @date + 70
end
else if (@month>6) and (@day>30)
begin
set @day= 1
set @month = @month + 1
set @date = @date + 71
end
else
set @date = @date + 1
end
delete from #tblDate where dt=(select top 1 dt from #tblDate order by dt desc)
select * from #tblDate
drop table #tblDate
SELECT DB_NAME(database_id),
COUNT (1) * 8 / 1024 AS MBUsed
FROM sys.dm_os_buffer_descriptors
GROUP BY database_id
ORDER BY COUNT (*) * 8 / 1024 DESC
GO
جهت انجام تاخیر در دستورات TSQL باید از دستور زیر استفاده شود:
WAITFOR DELAY '00:00:01'
SELECT dbo.staff.id, dbo.staff.fullName, dbo.staff.dressCode, dbo.staff.lockerCode, dbo.staff.staffCode,
[dbo].[getCountOfStaffUnavailableDocumnet](dbo.staff.id) as unavailableDocumnet,
(select ' - ' + titleFa from allType where parent = 228 and id not in (select documentType from staffDocument where staff_id=dbo.staff.id)
and id not in(231,236,248,251,255,256)
order by titleFa
FOR XML PATH('')) as unavailableDocumnetTitle,
allType_restaurant.titleFa AS restaurant, allType_position.titleFa AS position, allType_jobStatus.titleFa AS jobStatus
FROM dbo.staff INNER JOIN
dbo.allType AS allType_restaurant ON dbo.staff.restaurant = allType_restaurant.id INNER JOIN
dbo.allType AS allType_position ON dbo.staff.position = allType_position.id INNER JOIN
dbo.allType AS allType_jobStatus ON dbo.staff.jobStatus = allType_jobStatus.id
ORDER BY dbo.staff.id DESC
select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0)
DECLARE @PageNumber AS INT, @RowspPage AS INT
SET @PageNumber = 6
SET @RowspPage = 5
SELECT * FROM (
SELECT ROW_NUMBER() OVER(ORDER BY id) AS NUMBER,
* FROM tableType
) AS TBL
WHERE NUMBER BETWEEN ((@PageNumber - 1) * @RowspPage + 1) AND (@PageNumber * @RowspPage)
ORDER BY id