Forum
Merhaba iyi forumlar.
Sorunum CHARINDEX le başlangıç ve bitiş yeri güzelce seçiliyor fakat sorunum şu ;
----- KOD ----
Select SUBSTRING(strDesc,CHARINDEX('(',strDesc),(CHARINDEX(')',strDesc))-CHARINDEX('(',strDesc)) as User
from _LogEventChar
where EventID='20'
ORDER BY EventTime DESC
----------------------------
Sonuç işe şu şekilde ;
(Kofti
(SeveriaN
(Energy
(Yorouchi
Yani bitiş olarak ")" işaretinden öncekileri alıyor fakat başlangıç olarak "(" işareti yaptığımda ise başlarında ( çıkıyor.
strDesc Column u örnek bu şekilde normalde "[My no job Kirin His(Energy) Neutral"
Kullanıcılar binlerce olduğu için çok sorun yaşıyorum.
Şimdiden teşekkürler.
Merhaba İsa bey,
strDesc sütunu ile ilgili yani CHARINDEX kullanımı yaptığınız sütundan 10 adet örnek verebilir misiniz?
Örneklere sanırım gerek kalmadı,
Yapacağınız SQL Sorgusunu aşağıdaki gibi deniyebilir misiniz?
Select SUBSTRING(
strDesc ,CHARINDEX('(',
strDesc )+1,(CHARINDEX(')',
strDesc ))-CHARINDEX('(',
strDesc )-1) as [User] from _LogEventChar WHERE EventID='20' ORDER BY EventTime DESC
Hata olarak bunu verdi
Invalid length parameter passed to the SUBSTRING function.
Sadece ilk CharIndex sonunda -1 Kullandım sonuç olarakta bunu verdi.
Bu Seferde parantez Sonunda çıktı.
Energy)
Energy)
SeveriaN)
Energy)
SeveriaN)
SeveriaN)
SeveriaN)
Yorouchi)
Kofti)
Kofti)
4CocuKEvKira)
Yorouchi)
Kofti)
SeveriaN)
Kofti)
Energy)
Kofti)
SeveriaN)
SeveriaN)
SeveriaN)
Kofti)
_Quest)
4CocuKEvKira)
Pederaz)
Kofti)
4CocuKEvKira)
SeveriaN)
4CocuKEvKira)
4CocuKEvKira)
By_MechuL)
SeveriaN)
Energy)
Rene)
Rene)
Rene)
Pederaz)
Pederaz)
SeveriaN)
Kofti)
Bong)
Rene)
Pederaz)
Kofti)
MedquaLity)
Pederaz)
MedquaLity)
_Quest)
MedquaLity)
Pederaz)
SeveriaN)
SeveriaN)
SeveriaN)
_Quest)
SeveriaN)
_Quest)
SeveriaN)
SeveriaN)
MedquaLity)
SeveriaN)
SeveriaN)
4CocuKEvKira)
Energy)
SeveriaN)
MedquaLity)
SeveriaN)
Energy)
SeveriaN)
Energy)
SeveriaN)
SeveriaN)
SeveriaN)
Energy)
Energy)
Energy)
Energy)
SeveriaN)
SeveriaN)
Energy)
SeveriaN)
Energy)
SeveriaN)
SeveriaN)
Energy)
Energy)
Doloritas)
SeveriaN)
Energy)
Energy)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
SeveriaN)
Energy)
SeveriaN)
Energy)
SeveriaN)
SeveriaN)
SeveriaN)
Doloritas)
Energy)
_Quest)
WitchBIade)
_Quest)
İlk charindex te +1 son charindex te -1 denediniz mi ?
https://docs.google.com/open?id=0B-4LfaCX5TC9NzlMcWRTN29wUGs
Adresinde yaptığım örnek şu şekilde
Evet denedim Sonuç olarak ilk ilk select fonksiyonu çalışıyor fakat ikincisi çalışmıyor.
Size strDesc Column'daki örnekleri veriyorum
------
[My: no job, Neutral, Kirin] [His(EziKDeDiTeK7): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(EziKDeDiTeK7): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(RouTeR): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(RouTeR): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(RouTeR): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(RouTeR): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(RouTeR): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(_Quest): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Rene): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(_Quest): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(_Quest): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Rene): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Rene): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Rene): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Rene): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(WitchBIade): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, HyeonMu] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(TheSlayeR): no job, Neutral, Kirin]
[My: no job, Neutral, HyeonMu] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(JuLieT): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, HyeonMu] [His(Pederaz): no job, Neutral, BackHo]
[My: no job, Neutral, Kirin] [His(AHMET): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(Pederaz): no job, Neutral, HyeonMu]
[My: no job, Neutral, Kirin] [His(SeveriaN): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(SeveriaN): no job, Neutral, Kirin]
[My: no job, Neutral, Kirin] [His(SeveriaN): no job, Neutral, Kirin]
------
Datalarınızı isterseniz kontrol edin bende herhangi bir sorun olmadı.
Örnek;
https://docs.google.com/open?id=0B-4LfaCX5TC9Q1d2Szl2OXNpUms
Tamam resimdeki Query kodu yukarıda verdiğiniz ile aynımı acaba.
yada Siz yazabilirseniz buraya sevinirim yeni kalktık gözler seçmiyor 🙂
Evet yukarıdaki ile aynı kodlardır.
İyi çalışmalar.
--------------------------------
Select SUBSTRING( strDesc ,CHARINDEX('(', strDesc )+1,(CHARINDEX(')', strDesc ))-CHARINDEX('(', strDesc )-1) as [User]
from _LogEventChar
where EventID='20'
ORDER BY EventTime DESC
select * from _LogEventChar
Where EventID='20'
----------------------
Bu kodu denediğimde ilk selec substring kodunun verdiği hata "Invalid length parameter passed to the SUBSTRING function."
neden olabilir veya kodda atladığım birşeymi var ?
SQL server 2005
Datalarınızda bir farklılık görünüyor sanırım. TOP 100 yaparak denermisiniz birde ilk 100 satırde deneyin bakalım birde
Denedim 100 , 5 ,1 🙂
aynı Hata neden olabilir bilmiyorum site o Tablonun oluşturma dosyasınıda göstereyim.
-------------------------------------------
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[_LogEventChar](
[CharID] [int] NOT NULL,
[EventTime] [datetime] NOT NULL,
[EventID] [tinyint] NOT NULL,
[Data1] [int] NOT NULL,
[Data2] [int] NOT NULL,
[EventPos] [varchar](64) NULL,
[strDesc] [varchar](128) NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
----------------------------------------
Teşekkür Ederim yardımın için sorunum çözüldü..
Kafanız karışmasın diye Where komutlarıyla beraber yazmadım
strDesc teki null yerler ve başka yazılarda olduğu için o tabloda o hatayı vermiş..
ama Where komutlarını ekleyince sorun düzeldi.
teşekkürler