Sayfalar

Sql Funcitons etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Sql Funcitons etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

8 Eylül 2019 Pazar

STORED PROCEDURES


STORED PROCEDURE

Parametresiz Procedure

CREATE PROC SelectAllCustomers
AS
SELECT * FROM Customers
GO;

.
.
.
.

EXEC SelectAllCustomers;



Parametreli Str. Procedure

CREATE PROC SelectAllCustomers
(
  @City nvarchar(30)
)
AS
SELECT * FROM Customers WHERE City = @City
GO;

.
.
.
.
EXEC  SelectAllCustomers City='Berlin'


ÖRNEK:

create PROCEDURE sp_CustSatisToplamBwDates 
(
@DateBegin datetime
@DateEnd datetime
)
AS
SELECT SUM(SD.BirimFiyati*SD.Miktar) AS TOTALSATIS FROM Personeller P
INNER JOIN Satislar S ON S.PersonelID=P.PersonelID
INNER JOIN [Satis Detaylari] SD ON SD.SatisID= S.SatisID
WHERE S.SatisTarihi>=@DateBegin and s.SatisTarihi<=@DateEnd
GO



ÇAĞIRILIŞI:


exec CustSatisToplamBwDates @DateBegin='1989-01-01',@DateEnd='2000-01-01' 

 

7 Eylül 2019 Cumartesi

DATEADD() Function

The DATEADD() function adds a time/date interval to a date and then returns the date.


DATEADD(interval, number, date)


Select DATEADD(Year,1,'2017/08/01')

Select DATEADD(Year,1,'2017-08-01')

Select FirstName, BirthDate, DATEADD(Year,18,BirthDate) From Employees



Parameter Description
interval Required. The time/date interval to add. Can be one of the following values:
  • year, yyyy, yy = Year
  • quarter, qq, q = Quarter
  • month, mm, m = month
  • dayofyear = Day of the year
  • day, dy, y = Day
  • week, ww, wk = Week
  • weekday, dw, w = Weekday
  • hour, hh = hour
  • minute, mi, n = Minute
  • second, ss, s = Second
  • millisecond, ms = Millisecond
number Required. The number of interval to add to date. Can be positive (to get dates in the future) or negative (to get dates in the past)
date Required. The date that will be modified

CURRENT_TIMESTAMP


The CURRENT_TIMESTAMP function returns the current date and time, in a 'YYYY-MM-DD hh:mm:ss.mmm' format.

Select CURRENT_TIMESTAMP    //Sonuç 2019-09-07 11:45:38.000

DATEFROMPARTS() Function


The DATEFROMPARTS() function returns a date from the specified parts (year, month, and day values).

DATEFROMPARTS(year, month, day)

Select DATEDIFF(year,DateFromParts(2012,08,1), DATEFROMPARTS(2019,08,31)) //Sonuç 7 

Parameter Description
year Required. Specifies a year (4 digits)
month Required. Specifies a month (from 1 to 12)
day Required. Specifies a day (from 1 to 31)

MVC LOADING TOO SLOW ISSUE