7 Ocak 2015 Çarşamba

sysobjects tablosundaki xtype açıklamaları

———- sysobjects tablosundaki xtype açıklamaları

/*** XTYPE

C = CHECK constraint


D = Default or DEFAULT constraint


F = FOREIGN KEY constraint


L = Log


FN = Scalar function


IF = In-lined table-function


P = Stored procedure


PK = PRIMARY KEY constraint (type is K)


RF = Replication filter stored procedure


S = System table


TF = Table function


TR = Trigger


U = User table


UQ = UNIQUE constraint (type is K)


V = View


X = Extended stored procedure


****/


——- sysobjects içindeki type tanımlamaları ————-

/**** TYPE

C = CHECK constraint


D = Default or DEFAULT constraint


F = FOREIGN KEY constraint


FN = Scalar function


IF = In-lined table-function


K = PRIMARY KEY or UNIQUE constraint


L = Log


P = Stored procedure


R = Rule


RF = Replication filter stored procedure


S = System table


TF = Table function


TR = Trigger


U = User table


V = View


X = Extended stored procedure


**********/


exec usp_ListCustomers

go

execute usp_ListCustomers

go

usp_ListCustomers

go


alter procedure usp_ListCustomers

as

select CustomerID,CompanyName from customers

where Country = ‘UK’

go


drop procedure usp_ListCustomers


select * from [order details]

–declare @pid int

–set @pid = 111


alter proc usp_GetTotalbyProductID

@pid int

as

IF EXISTS (select productID from [order details] where ProductID = @pid)

begin

select SUM(Unitprice * Quantity) as ‘Total’

from [order details]

where ProductID = @pid

end


ELSE

raiserror(‘Unmatched ProductID…’,14,1)

return

GO


exec usp_GetTotalbyProductID 11

select top 2 * from [order details]

select * from orders

select top 2 * from customers

select top 2 * from products


declare @startdate datetime , @enddate datetime

set @startdate = ‘19960701 00:00:00′

set @enddate = ‘19960801 00:00:00′


create procedure usp_GetTotalReport

@startdate datetime ,

@enddate datetime

as


select p.productname , sum(od.unitprice * od.quantity) as total

from [order details] od inner join orders o

on o.orderID = od.OrderID

inner join products p

on p.productID = od.productID

where o.orderdate between @startdate and @enddate

group by p.productname

order by p.productname


GO


usp_GetTotalReport ‘19960701 00:00:00′,’19960801 00:00:00′


create proc topla2

@sayi1 int,

@sayi2 int,

@sonuc int output

with recompile

as

select @sonuc = @sayi1 + @sayi2

GO


declare @sonuc int

EXEC topla 1,2,@sonuc output

select @sonuc


sp_recompile topla

declare @startdate datetime , @enddate datetime

set @startdate = ‘19960101 00:00:00′

set @enddate = ‘20060801 00:00:00′


alter proc usp_deleteproduct

@pid int

as

delete from products where productID = @pid


if @@rowcount = 0

begin

print ‘Hata oluştu…’

return 99

end


else

print ‘Product that has the number’ + cast(@pid as varchar(10)) + ‘was deletede successfully’

return 0

go


usp_deleteproduct 11



sysobjects tablosundaki xtype açıklamaları

6 Ocak 2015 Salı

Sql Update replace kullanımı

Merhaba,


Bu makalemizde sql ile yani t-sql ile update komutu ile birlikte replace komutunun nasıl kullanıldığı anlatılacaktır.


Replace komutu kullanımı çok kolaydır.Aşağıda microsoft msdn kullanımı verilmiştir.


SELECT Replace(‘Sqlogren.com Sqlogrenmenin Tam Zamanı!’, ‘Tam’, ‘Yarım’)


Geri dönüş result ekranı şu şekide olacaktır.

Sqlogren.com Sqlogrenmenin Yarım Zamanı!


Şimdi bunu bir tablo için nasıl yapılacağını görelim.


SELECT Replace(Tablo_adı, ‘Değişecek Kelime’, ‘Yerine gelicek Kelime’) from tabloadı


şeklinde olacaktır.


Burda çok karşılaştığımız hatalardan biri olarak


SELECT Replace(‘SQLOgren.com Öğrenin!’, ‘Tam’, ‘Zamanı’)

Bize geri dönüşü şu şekilde olacaktır


SQLOgren.com Öğrenin! Çünkü değiştirilecek kelime içinde değiştirmek istediğiniz kelime yok ve bu sebeple değişiklik yapılmadı.


Bir tablo ile update ve replace fonksiyonunu kullanımı örneği;


Update dbo.kullanicilar

Set sehirler= replace(sehirler, ‘Istanbul’, ‘Istanbul_sqlogren’);


Bu bize kullanicilar tablosundaki sehirler sütunundaki tüm Istanbul yazan yerlere Istanbul_sqlogren kelimesini değiştirdiğini göreceksiniz.


Hepsi bu kadar kolay gelsin.



Sql Update replace kullanımı

HALK TV CANLI YAYIN

HALK TV CANLI YAYIN İZLE



Halk tv üzerinden canlı yayın yapan halk tv sqlogren.com üzerinden izleyebilirsiniz.



HALK TV CANLI YAYIN

5 Ocak 2015 Pazartesi

Trigger Nedir Nasıl Kullanılır



CREATE

DROP

ALTER

INSERT

UPDATE

DELETE


BU İŞLEMLERİN HERHANGİ BİRİ YAPILDIĞI ZAMAN TRIGGER ÇALIŞIR (TETİKLEYİCİ)


Trigerin çalışması için sql agent ın çalışması gerekiyor

Genelde kullanılması tercih edilmez Kendi başlarına çalışırlar onun için…

Trigger a yaptığımız şeyleri stored procosedürlere tanımlayarak job bölümünden aynı işleri yaptırabilriz

select * from employees


alter table employees

add driverno varchar(15) null


— create trigger

for

instea of after dan sonra

delete,update,insert kullanılır


for delete,update,insert yapılıdığı anda bu işi yap

after delete,update,insert işlem yapıldıktan sonra bu işi yap demek

instea ise yapılan işlemi discard ederek kendisine yanımlanan işlemi yaptırır.

alter trigger Makeuniquedriverno

on employees –hangi table üzerinde çalışığını belirtiyorz

for insert,update — insert ve update oldupunda

as

if update(driverno) — employesin üzerinde çalışırkken yaplıan update içerisinde driver no update oluyosa

if exists ( select driverno from employees

where driverno is null and

driverno in (select distinct (driverno) from inserted)– eğer girilen veri drivernoda varsa

)

begin

select distinct (driverno) from inserted


raiserror (‘Driverno sistemde mevcuttur.’,16,1)

rollback tran

end– yapılan işlemli geri al


–trigerda özel 2 tablo var 1 inserted ve 2. deleted

–insert ve update olduğu zaman inserted da bekler

— girilen veriye kısıt verildiyse veri girildikten sonra kontrol için

— bi yerde beklemesi gerekiyor bunun için inserted da bekliyor.

–bi kayıt silinirse deleteed ı girer.


update employees

set driverno = ‘12345’


update employees

set driverno = ‘12347’

where employeeID = 1


select * from employees

alter trigger Makeuniquedriverno

on employees –hangi table üzerinde çalışığını belirtiyorz

for insert,update — insert ve update oldupunda

as


declare @driverno varchar(15)

declare @employeeID int

declare @intdriverno int


select @driverno = driverno , @employeeID=employeeID from inserted

set @newdriverno = (select convert(int,max,driverno)) + 1 from employees


if update(driverno)

begin

if exists ( select top 1 employeeID from employees

where driverno = @driverno

begin

update employees

set driverno = convert(varchar(15),@newdriverno)

where employeeID =@employeeID

select ‘driverno değiştirilecek kaydedildi…’

end

else

begin

update employees

set driverno @driverno

where employeeID = @employeeID

select ‘ driverno değiştirilmeden kaydedildi…’

end

end


 


create table triggertest

(

testId int not null primary key identity(1,1),

testAdi varchar(50) null,

testaciklama varchar(100)

)


declare @counter int

set @counter = 1


declare @testadi varchar(50)

declare @testaciklama varchar(100)

set @testadi = ‘test’

set @testaciklama = ‘Açıklama’

while @counter <= 20

begin


set @testadi = @testadi + convert(varchar(10),@counter)


insert into triggertest

values(@testadi,@testaciklama)

set @counter = @counter + 1

end


select * from triggertest


create trigger deleteonce

on triggertest

for delete

as

if (select count(*) from deleted) > 1

begin

raiserror (‘aynı anda birden fazla kayıt silemezsiniz.’,16,1)

rollback tran

end

delete from triggertest

where testID>1 — bu çalıştı ve birden fazla kayıt sildirmiyyor..


create table urunler

(

urunId int not null identity(1,1) primary key,

urunadi varchar(50) not null,

miktar int not null default(0)

)

create table musterisiparisleri

(

siparisId int not null identity(1,1) primary key,

urunId int not null,

miktar int not null default(0)

)


create table sirketsiparisleri

(

siparisId int not null identity(1,1) primary key,

urunId int not null,

miktar int not null

)


declare @urunadi varchar(50)

declare @miktar int

declare @counter int

set @counter = 1


while @counter <= 20

begin

set @urunadi = ‘ürün ‘ + convert (varchar(10),@counter)

set @miktar = 10 * @counter


insert urunler

values(@urunadi,@miktar)

set @counter = @counter + 1

end


alter table kullanicilar

(

kullaniciID int not null identity(1,1) primary key,

adsoyad varchar(100) not null,

kullanicitipi tinyint not null default(2))

— 1: Admin 2: Normal Kullanıcı

)


insert kullanicilar

values(‘Hasan Mansur’ ,1)


insert kullanicilar(adsoyad,kullanicitipi)

values(‘Murat KARAKUŞ’,1)


insert kullanicilar

values(‘Cafer KARAKUŞ’,2)


insert kullanicilar

values(‘mEHmet ÖZNUR’,2)


insert kullanicilar

values(‘Hasan Hüseyin’,2)


insert kullanicilar

values(‘Zeynel Yasan’,1)


select * from kullanicilar


truncate table kullanicilar — truncate


alter table admin

(

KullaniciId int not null primary key,

durum tinyint not null default(1) –0 silindi ; 1: Aktif


)

— trigger

alter trigger adminlog

on kullanicilar

for insert , update

as


declare @inserted_adsoyad varchar(100)

declare @inserted_KullaniciTipi tinyint

declare @yenikullaniciId int

declare @updated_kullaniciID int


select @inserted_adsoyad = Adsoyad,

@inserted_KullaniciTipi = KullaniciTipi

from inserted


–update için bundan sonrası


if update (KullaniciTipi)


begin


set @updated_kullaniciID = (select kullaniciId from inserted)

— yeni kullanıcı tipi admin ise

if @inserted_KullaniciTipi = 1

begin

— eğer bu kullanıcı admin tabloasunda yoksa ise ekle

if not exists(select top 1 kullaniciID from admin where KullaniciID =@updated_kullaniciID)

begin

insert admin

values (@updated_kullaniciID)


print ‘kayıt admine eklendi’

end

end

else — kullanıcı yeni ise tipi = 2 yani normal kullanıcı

begin

–eğer bu kullanıcı tipi varsa sil

if exists(select top 1 kullaniciID from admin where KullaniciID = @updated_kullaniciID)

begin

insert admin

values (@updated_kullaniciID)

print ‘kayıt adminden silindi Vallaha’

end

end


 

if @inserted_KullaniciTipi = 1


begin

select @yenikullaniciID = @@identity — kullanıcının verilen ID nin dönmesi görmek için

insert admin values(@yenikullaniciId,1)

print ‘Kullanıcı Tipi Admine Yazıldı’

end

else

print ‘Kullanıcı Tipi Admine Yazılmadı’


select * from admin



Trigger Nedir Nasıl Kullanılır

Sql Cursor Örnekleri

select lastname, firstname from employees

order by lastname, firstname

declare contact_cursor scroll cursor for

select lastname, firstname from employees

order by lastname, firstname

open contact_cursor


— en sondaki kayıt

fetch last from employee_cursor


–en sondaki kayıtta kaldıyda ondan bir öncekk kayıt

fetch prior from employee_cursor


— cursor ın bulunduğu yerden 2 ilerideki kayıt

fetch absolute 2 from employee_cursor


— bulunduğu yerden 3 sonraki kayıt

fetch relative 3 from employees_cursor

— bir sonrakine gider

FETCH NEXT FROM employees_cursor


— bulunduğu yerden 2 önceki kayıt

fetch relative 2 from employees_cursor


close employee_cursor

DEALLOCATE emloyee_cursor

go

— prior en son kayıtta kalır bi öncekine birini gönderiri o-kutur..


— absolute ileri iki sonda kayıt kalmadıysa başadöner ilk iki kayıdı okur cursomrı gördüğü yerden sayar.cursordan sonra sayama başlar

–realive ise kendisinin en son okuduğu yerden okumaya devam eder

–en sonda yazılan kod deallocate remi boşaltamya yarar.

–priordan sonra relative çalışırırsan priordan sonra saymaya başlar.



declare @empfirstname varchar(50),@emplastname varchar(50)


declare @empcursor cursor for

select lastname, firstname from employees

order by lastname, firstname


open @empcursor


fetch next from empcursor

into @emplastname,@empfirstname — selectde ne okuduyda ona göre sıralamak zorundayız

while @@fetch_status = 0

begin


print ‘employee :’ + @empfirstname + ‘ ‘ @emplastname


fetch next from empcursor

into @emplastname,@empfirstname

end

close empcursor

deallocate empcursor

go

SELECT OD.PRODUCTID,SUM(OD.QUANTITY) AS ‘QUANTITY’,

SUM(P.UNITSINSTOCK) AS

CASE WHEN SUM(

FROM [ORDER DETAILS] OD INNER JOIN PRODUCTS P

ON OD.PRODUCTID = P.PRODUCTID


SELECT * FROM KULLANICILAR


DECLARE @kullaniciID int,@adsoyad varchar(50), @kullanicitipi int


declare @temp_kullanicilar table

(kullaniciId int,

adsoyad varchar(50),

kullanicitipi int

)


declare kul_cursor cursor fast_forward read_only for


select kullanicilarId , adsoyad,kullanicitipi

from kullanicilar

order by 1 asc


open kul_cursor cursor

fetch next from kul_cursor

into @kullaniciId , @aysoyad, @kullanicitipi

while @@fetch_status


begin


if exists (select top 1 kullanicilarID from @temp_kullanicilar

where adsoyad = @adsoyad

begin

if (select kullanicitipi from @temp_kullanicilar

where adsoyad =@adsoyad)

end

end


close kul_cursor

deallocate kul_cursor

go



Sql Cursor Örnekleri

4 Ocak 2015 Pazar

Sql View Örnekleri

select top 2 * from dbo.Customers

select top 2 * from orders

select top 2 * from [order details]

select top 2 * from dbo.Products

select top 2 * from dbo.Employees


create view SalesDetails

AS

–CustomersName — ProductName — Quantity

select E.FirstName +’ ‘+ E.LastName as ‘Full Name’

,C.ContactName , P.ProductName , OD.Quantity

from [Order Details] OD inner join Orders O

on OD.OrderID = O.OrderID

inner join Customers C

on O.CustomerID = C.CustomerID

inner join Employees E

on O.EmployeeID = E.EmployeeID

inner join Products P

on OD.ProductID = P.ProductID

select * from SalesDetails


sp_help SalesDetails


sp_helptext SalesDetails


sp_depends SalesDetails


select * from INFORMATION_SCHEMA.TABLES

where table_name = ‘SalesDetails’


select * from INFORMATION_SCHEMA.VIEWS

where table_name = ‘SalesDetails’

create view AmericanCustomers

AS

select * from customers

where country = ‘usa’


select * from AmericanCustomers


alter table customers

add MobilePhone varchar(15) null


select * from customers


sp_depends AmericanCustomers


create view OgretmenDers

as

select O.Adi + ‘ ‘ + O.Soyadi as ‘OgretmenAdi’

,D.DersAdi

from Ogretmenler O inner join Dersler D

on O.DersID = D.DersID


select * from OgretmenDers


sp_refreshview AmericanCustomers


sp_depends AmericanCustomers


select * from AmericanCustomers


create view UKCustomers

with encryption

as

select * from customers

where country = ‘uk’

select * from UKCustomers

sp_depends UKCustomers

sp_helptext UKCustomers

select * from INFORMATION_SCHEMA.VIEWS

where table_name = ‘UKCustomers’

select * from ogretmenler

select * from ogretmenders


drop view OgretmenDers


create view OgretmenDers

with schemabinding

as

select O.Adi + ‘ ‘ + O.Soyadi as ‘OgretmenAdi’

,D.DersAdi

from dbo.Ogretmenler O inner join dbo.Dersler D

on O.DersID = D.DersID

select * from OgretmenDers


delete from dersler

where dersid = 7


sp_helptext OgretmenDers


drop table ogretmenler


alter view OgretmenDers

as

select O.Adi + ‘ ‘ + O.Soyadi as ‘OgretmenAdi’

,D.DersAdi

from dbo.Ogretmenler O inner join dbo.Dersler D

on O.DersID = D.DersID


create view BrazilianCustomers

as

select * from customers

where country = ‘Brazil’

with check option


update BrazilianCustomers

set country = ‘Turkey’

where customerID = ‘FAMIA’


select top 2 * from employees

select top 2 * from dbo.EmployeeTerritories

select top 2 * from dbo.Territories

select top 2 * from region



Sql View Örnekleri

Create Trigger ile otomatik kayıt girişi

select * from employees


alter table employees

add DriverNo varchar(15) null


alter trigger MakeUniqueDriverNo

on employees

instead of insert , update

as


declare @driverno varchar(15)

declare @employeeID int

declare @newDriverno int


select @driverno=driverno ,@employeeID=employeeID from inserted

set @newDriverno =(select convert(int,max(driverno)) + 1 from employees)


if update(driverno)

begin

if exists ( select top 1 employeeID from employees

where driverno = @driverno)

begin

update employees

set driverno = convert(varchar(15),@newDriverno)

where employeeID = @employeeID

select ‘Driverno değiştirilerek kaydedildi…’

end

else

begin

update employees

set driverno = @driverno

where employeeID = @employeeID

select ‘Driverno değiştirilmeden kaydedildi…’

end

end


—- test

update employees

set driverno = ‘12343’

where employeeID = 7


select driverno from employees


create table TriggerTest

(

testID int not null primary key identity(1,1),

testAdi varchar(50) null,

testAciklama varchar(100) null

)


declare @counter int

set @counter = 1


declare @testAdi varchar(50)

declare @testAciklama varchar(100)

set @testAdi = ‘test ‘

set @testAciklama = ‘Açıklama ‘


while @counter <= 20

begin

set @testAdi = @testAdi + convert(varchar(10),@counter)

set @testAciklama = @testAciklama + convert(varchar(10),@counter)


insert into TriggerTest

values(@testAdi,@testAciklama)


set @counter = @counter + 1

end


select * from TriggerTest


create trigger deleteOnce

on TriggerTest

for delete

as

if(select count(*) from deleted ) > 1

begin

raiserror(‘Aynı anda birden fazla kayıt silemezsiniz’,16,1)

rollback tran

end


delete from TriggerTest

where testID > 1


create table urunler

(

UrunID int not null identity(1,1) primary key,

UrunAdi varchar(50) not null,

Miktar int not null default(0)

)


create table MusteriSiparisleri

(

SiparisID int not null identity(1,1) primary key,

UrunID int not null,

Miktar int not null

)


create table SirketSiparisleri

(

SiparisID int not null identity(1,1) primary key,

UrunID int not null,

Miktar int not null

)

declare @urunAdi varchar(50)

declare @miktar int

declare @counter int

set @counter = 1


while @counter <= 20

begin

set @urunAdi = ‘Ürün ‘ + convert(varchar(10),@counter)

set @miktar = 10 * @counter


insert MusteriSiparisleri

values (@urunAdi , @miktar)


set @counter = @counter +1

end


select * from urunler


create trigger SiparisKontrol

on MusteriSiparisleri

for insert , update

as


declare @girilenUrunID int

declare @girilenMiktar int

declare @miktarFark int


select @girilenUrunID = UrunID , @girilenMiktar=Miktar

from inserted


if (select Miktar from Urunler where UrunID = @girilenUrunID) < @girilenMiktar

begin

set @miktarFark = @girilenMiktar – (select Miktar from Urunler where UrunID = @girilenUrunID)


update urunler

set miktar = 0

where UrunID = @girilenUrunID


insert SirketSiparisleri

values (@girilenUrunID,@miktarFark)

end


else

begin

update urunler

set miktar = miktar – @girilenMiktar

where UrunID = @girilenUrunID

end


select * from urunler

select * from MusteriSiparisleri

select * from SirketSiparisleri

insert MusteriSiparisleri

values (10,100)

insert MusteriSiparisleri

values (8,100)


—————————————————–

create table Kullanicilar

(

KullanaciID int not null identity(1,1) primary key,

AdSoyad varchar(100) not null,

KullaniciTipi tinyint not null default(2)

— 1 : admin ; 2: Normal

)


insert Kullanicilar

values (‘Hasan Mansur’ , 1)


insert Kullanicilar

values (‘Nalan Arıcı’ , 2)


insert Kullanicilar

values (‘Mehmet Çakmak’ , 1)


insert Kullanicilar

values (‘Özgür Gül’ , 2)


insert Kullanicilar

values (‘Murat Karakuş’ , 1)


insert Kullanicilar

values (‘Aylin Aydın’ , 2)


insert Kullanicilar

values (‘Murat Çakıcı’ , 1)


select * from Kullanicilar

truncate table Kullanicilar


create table Admin

(

KullaniciID int not null primary key,

Durum tinyint not null default(1) — 0: silindi ; 1:Aktif

)


alter trigger AdminLog

on Kullanicilar

for insert , update

as


declare @inserted_AdSoyad varchar(100)

declare @inserted_KullaniciTipi tinyint

declare @yeni_KullaniciID int

declare @updated_KullaniciID int


select @inserted_AdSoyad = AdSoyad

,@inserted_KullaniciTipi = KullaniciTipi

from inserted


——————- update ———————–

if update (KullaniciTipi)

begin

set @updated_KullaniciID = (select KullanaciID from inserted)

if @inserted_KullaniciTipi = 1 — yeni kullanicitipi admin ise

begin

— eğer bu kullanıcı admin tablosunda yoksa , ekle

if not exists (select top 1 KullaniciID

from Admin where KullaniciID = @updated_KullaniciID)

begin

insert Admin values(@updated_KullaniciID,1)

print ‘Kayıt admine eklendi…’

end

end

else — eğer yeni kullanıcı tipi = 2 yani normal kullanıcı ise

begin

— eğer bu kullanıcı adminde varsa , sil

if exists (select top 1 KullaniciID

from Admin where KullaniciID = @updated_KullaniciID)

begin

delete from Admin

where KullaniciID = @updated_KullaniciID

print ‘Kayıt adminden silindi…’

end

end

end

————————— insert ————————-

else

begin

if @inserted_KullaniciTipi = 1

begin

select @yeni_KullaniciID = @@identity

insert Admin values(@yeni_KullaniciID,1)

print ‘KullanıcıTipi Admine yazildi’

end

else

print ‘Kullanıcı normal tiptedir.Admine yazilmadi’

end


select * from admin


select * from kullanicilar


update kullanicilar

set KullaniciTipi = 2

where KullanaciID = 2


insert kullanicilar values(‘Murat BeyazKuş’,1)

create table Silinenler

(

KullanaciID int not null primary key,

AdSoyad varchar(100) not null,

KullaniciTipi tinyint not null default(2) ,

— 1 : admin ; 2: Normal

IslemTarihi datetime not null default(getdate())

)


alter trigger SilveLogla

on Kullanicilar

instead of delete

as

declare @KullanaciID int ,@AdSoyad varchar(100),

@KullaniciTipi tinyint


select @KullanaciID=KullanaciID

,@AdSoyad=AdSoyad

,@KullaniciTipi = KullaniciTipi

from deleted


— 2 iş var

–1 silinenlere yaz

–2 kullanicilar dan sil

–3 bu @KullanaciID adminde varsa sil


–1

insert silinenler

values(@KullanaciID,@AdSoyad,@KullaniciTipi,getdate())

print cast(@KullanaciID as varchar(10)) + ‘ nolu ‘

+ @AdSoyad +’ adlı kayıt silinenler tablosuna yazıldı.’


–2

delete from kullanicilar

where KullanaciID = @KullanaciID


print cast(@KullanaciID as varchar(10)) + ‘ nolu ‘

+ @AdSoyad +’ adlı kayıt kullanicilar tablosundan silindi.’


–3

if exists ( select top 1 KullaniciID

from Admin where KullaniciID = @KullanaciID)

begin

delete from admin

where KullaniciID = @KullanaciID


print cast(@KullanaciID as varchar(10)) + ‘ nolu ‘

+ @AdSoyad +’ adlı kayıt admin tablosundan silindi.’


end


select * from silinenler

select * from admin

select * from kullanicilar


delete from kullanicilar

where KullanaciID in (2,3)



Create Trigger ile otomatik kayıt girişi

3 Ocak 2015 Cumartesi

northwind join işlemleri

use northwind

go

select * from dersler

select * from ogrenciler

select * from dbo.OgrenciDers


create view OgrenciKarne

as

select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu

from OgrenciDers OD inner join ogrenciler O

on OD.OgrenciID = O.OgrID

inner join Dersler D

on OD.DersID = D.DersID


select * from OgrenciKarne


create view DersNotAlmayanlar

as

select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is null or OD.Notu is null

select * from DersNotAlmayanlar


alter view DersNotAlmayanlar

as

select O.Adi as ‘Öğrenci Adı’, O.Soyadi as ‘Öğrenci Soyadi’,D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is null or OD.Notu is null

alter view DersNotAlmayanlar(OgrenciAdi,OgrenciSoyadi,DersinAdi,DersNotu)

as

select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is null or OD.Notu is null


sp_help DersNotAlmayanlar

sp_helptext DersNotAlmayanlar


select * from INFORMATION_SCHEMA.TABLES

where table_name=’DersNotAlmayanlar’


select * from INFORMATION_SCHEMA.VIEWS

where table_name=’DersNotAlmayanlar’


alter view DersNotAlmayanlar(OgrenciAdi,OgrenciSoyadi,DersinAdi,DersNotu)

with encryption

as

select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is null or OD.Notu is null


alter view OgrenciDurum

with schemabinding

as

select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu , OD.Durum

from dbo.OgrenciDers OD inner join dbo.ogrenciler O

on OD.OgrenciID = O.OgrID

inner join dbo.Dersler D

on OD.DersID = D.DersID


select * from OgrenciDurum


sp_helptext OgrenciDurum


update OgrenciDers

set Durum = (case when Notu >=50 then ‘Geçti’ else ‘kaldi’ end)



northwind join işlemleri

sql distinct join

select productID,ProductName , UnitPrice

from products

where UnitPrice > all

(select UnitPrice from products where categoryID=2)


select * from products


select distinct(ProductID) from [order details]


select OD.*,P.CategoryID

from [order details] OD inner join Products P

on OD.ProductID = P.ProductID

where P.CategoryID=2 and OD.OrderID between 10250 and 10300


select OD.*

from [order details] OD join (select ProductID from Products where categoryID=2) as P

on OD.ProductID = P.ProductID

where OD.OrderID between 10250 and 10300


declare @sayi int


–set @sayi = select count(*) from products where UnitsInStock < 5

select @sayi = count(*) from products where UnitsInStock < 5


select @sayi

if @sayi > 0

begin

select * from products where UnitsInStock < 5

end

else

select ‘Kritik bir durum yok’

———————————————————————

if(select count(*) from products where UnitsInStock < 5) > 0

begin

select * from products where UnitsInStock < 5

end

else

select ‘Kritik bir durum yok’

———————————————————————-

if exists (select top 1 ProductID from products where UnitsInStock < 5)

begin

select * from products where UnitsInStock < 5

end

else

select ‘Kritik bir durum yok’


select ProductID,ProductName

from products

where exists (

select P.ProductID

from products p left outer join [order details] OD

on p.productID = OD.ProductID

where OD.ProductID is null

)


declare @max money


select @max = max(unitprice)

from products

where categoryID = 3


select @max


select * from products

where unitprice > @max


— kategori id 3 olan ürenlerden kaç adet satılmış

declare @categoryid int

set @categoryid = 10


if exists (select top 1 categoryID from products where categoryID = @categoryid)

begin

select count(*)

from [Order Details] OD join Products P

on OD.ProductID = p.ProductID

where p.categoryID = @categoryid

end

else

begin

select ‘categoryID = ‘ + convert(varchar,@categoryid) + ‘ olan bir kategori yok!!!’

select ‘KATEGORILER’

select distinct(categoryID) from products

end

select * from [Order Details]

select top 3 * from products

select 0.0 as Discount

union all

select 0.10

union all

select 0.20

union all

select 0.30

select p.ProductID,Discount * 100 as ‘Discount’,

P.UnitPrice * ( 1-discount) as ‘Price’

from products p cross join

(select 0.0 as Discount

union all

select 0.10

union all

select 0.20

union all

select 0.30) as D

where p.productID = 10

select * from ogretmenler

select * from ogrenciler


select Adi , Soyadi from ogretmenler

union all

select Adi , Soyadi from ogrenciler

select * from ogrenciders


select O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu,

case when Notu between 85 and 100 then ‘*****’

when notu between 70 and 84 then ‘****’

when notu between 50 and 69 then ‘***’

when notu between 25 and 49 then ‘**’

when notu between 10 and 24 then ‘*’

else ‘–‘ end as ‘Durum’

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID


select OrderID,ProductID,(UnitPrice * Quantity) * ( 1 – Discount) as ‘Price’,Discount

from [order details]

compute sum((UnitPrice * Quantity) * ( 1 – Discount)),AVG(Discount)


select sum((UnitPrice * Quantity) * ( 1 – Discount)),AVG(Discount)

from [order details]


select top 5 with ties O.Adi , O.Soyadi ,D.DersAdi ,OD.Notu,

case when Notu between 85 and 100 then ‘*****’

when notu between 70 and 84 then ‘****’

when notu between 50 and 69 then ‘***’

when notu between 25 and 49 then ‘**’

when notu between 10 and 24 then ‘*’

else ‘–‘ end as ‘Durum’

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is not null and OD.Notu is not null

order by OD.Notu desc


select D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is not null and OD.Notu is not null

group by OD.Notu,D.DersAdi

with rollup


select D.DersAdi ,OD.Notu

from OgrenciDers OD right join ogrenciler O

on OD.OgrenciID = O.OgrID

left join Dersler D

on OD.DersID = D.DersID

where D.DersAdi is not null and OD.Notu is not null

group by D.DersAdi,OD.Notu

with cube



sql distinct join

2 Ocak 2015 Cuma

Örnek Delphi Projeleri 42 Adet

Delphi programlama diline yeni başlayanlar için bulunmaz 42 adet örnek delphi projeleri.


Projeleri incelerseniz delphinin nasıl bir dil olduğunu ve örnekleriyle birlikte daha kolay ve basit şekilde programlama yapabilirsiniz.


Burdan İndirin



Örnek Delphi Projeleri 42 Adet

Driver 3 Full + Crack + Serial İndir – 2013

 


 


driv3r-driver-3


 


 






















yun Adı :Driver 3
Oyunun Sürüm Adı :2013
Oyunun Çıkış Tarihi :5 Nisan 2013
Oyun Türü :Aksiyon,Yarış
Dosya Türü :İSO  
Dosya Boyutu :[1 PART]
Oyun Dili :İngilizce
Rar Şifresi :sqlogren.com
Crack :İçinde Mevcuttur.
 

Driv3r Reflections Interactive tarafından tasarlanılarak, Atari tarafından 2004 yılında piyasaya çıkarılan Driver serisinin üçüncü oyunudur.


 


Sistem Gereksinimleri


 


İşletim Sistemi: Microsoft Windows XP

İşlemci: Intel Pentium 4

Ram: 256 MB

Ekran Kartı: NVIDIA GeForce3


 


Oyun Videosu


Burdan İndirin Tek Link 3.47

yada vip file


Burdan İndirin Tek Link 3.47



Driver 3 Full + Crack + Serial İndir – 2013

1 Ocak 2015 Perşembe

Commandos Strike Force Full Tek Link İndir

g2301


43385


Bazı oyunlar vardır ki örnek olucak türden rakiplerine taklitten başka yaptırcak birşey bırakmayan. Gerek oyundaki yapay zeka, gerek kurgusu, gerekse oyunun oynanabilirliği ile kendi kategorisindeki oyunlara ışık tutabilicek bir oyundur Commandos. Güzel ve zevkli bir oyun olan bu Commandos’u oynamanızı tavsiye ediyoruz. Aşağıdaki linkten indirebilirsiniz.


Sistem Gereksinimleri:

İşletim Sistemi: Windows 2000/XP

İşlemci: P4 1.8 GHz

RAM:512 MB

Ekran Kartı:64 MB

HDD: 3.46 GB


Commandos Strike Force Full Tek Link İndir



Commandos Strike Force Full Tek Link İndir

Far Cry Full indir

Far Cry


Oyun Hakkında


Çıkış Tarihi : 2004

Oyun Türü : Aksiyon / FPS


Sistem Gereksinimleri


AMD Athlon 1 GHz ya da Pentium III 1 GHz

256 MB RAM

64 MB DirectX 9.0b uyumlu ekran kartı

Windows 98SE/2000/XP (sadece)

DirectX 9.0b uyumlu ses kartı

4x DVD ya da 16x CD-ROM

4 GB boş disk alanı


Oyundan Görüntüler


0000782500007826000078270000782800007830


Video


Linkler


Burdan indirin



Far Cry Full indir