CREATE OR ALTER PROC StokNo_Degistir
as
select Barkodu,COUNT(*) from StokBarkodlari GROUP BY Barkodu HAVING COUNT(*)>1
select Barkodu from StokBarkodlari where Barkodu in (select Barkodu  from StokBarkodlari GROUP BY Barkodu HAVING COUNT(*)>1)
select StokNo,COUNT(*) from STOKKARTI GROUP BY StokNo HAVING COUNT(*)>1
SELECT * FROM STOKKARTI WHERE StokNo  IN (select StokNo from STOKKARTI GROUP BY StokNo HAVING COUNT(*)>1) ORDER BY StokNo 
select * from StokBarkodlari where Barkodu=''
UPDATE STOKKARTI SET StokNo=NoId
UPDATE StokFiyat SET StokNo=(SELECT StokNo FROM STOKKARTI WHERE Kodu=StokFiyat.Kodu)
UPDATE StokBarkodlari SET StokNo=(SELECT StokNo FROM STOKKARTI WHERE Kodu=StokBarkodlari.StokKodu)
UPDATE Buton SET StokNo=(SELECT StokNo FROM STOKKARTI WHERE Kodu=Buton.ButonDegeri)
update ADIGSABITLER SET STOKNO =(SELECT MAX(StokNo) from STOKKARTI )+1
delete from StokBarkodlari where Barkodu=''

go
 
SELECT top 3 StokNo,* FROM STOKKARTI ORDER BY NoId DESC
SELECT top 3 StokNo,* FROM StokFiyat ORDER BY NoId DESC
SELECT top 3 StokNo,* FROM StokBarkodlari ORDER BY StokBarkodlariNoId DESC
SELECT top 3 StokNo no,* FROM STOKKARTI ORDER BY StokNo DESC
SELECT top 3 StokNo no,* FROM StokFiyat ORDER BY StokNo DESC
SELECT top 3 StokNo no,* FROM StokBarkodlari ORDER BY StokNo DESC
select * from STOKKARTI where StokNo=4746
select * from STOKKARTI where StokNo=4746
SELECT top 30 StokNo,* FROM StokFiyat ORDER BY NoId DESC



CREATE or alter PROC STOK_ARAMA @i nvarchar(30) , @no int 
AS
select Kodu,StokNo,* from STOKKARTI where Barkodu in (@i) or StokNo in ( @no )
select Kodu,StokNo,* from STOKKARTI where Kodu in (@i) or StokNo in  (@no)
select Kodu,StokNo,* from StokFiyat where Kodu in (@i) or StokNo in (@no)
select StokKodu ,StokNo,* from StokBarkodlari where Barkodu in (@i) or StokNo in (@no)
select StokKodu ,StokNo,* from StokBarkodlari where StokKodu in (@i) or StokNo in (@no)
GO
STOK_ARAMA 'T5',''
ALTER TABLE StokBarkodlari ADD CONSTRAINT UK_Barkodu UNIQUE(Barkodu)
ALTER TABLE STOKKARTI ADD CONSTRAINT UK_StokNo UNIQUE(StokNo)

select * from StokBarkodlari where Barkodu=''