0

After you declare a variable of type Datetime, the result as the query is successful. But also, I get the following error in end-stage Tiger2 Logo.

"incorrect syntax near the keyword 'declare' Native error:42000(156)"

The code is as follows.

DECLARE @Tarih1 DATETIME
DECLARE @Tarih2 DATETIME
SET @Tarih1 = Convert(DATETIME,'01.08.2011',104)
SET @Tarih2 = Convert(DATETIME,'30.09.2099',104)

SELECT
  Convert(Varchar,PLN.DATE_,104) AS 'Vade_TARİHİ', 
  Convert(Varchar,PLN.PROCDATE,104) AS 'İşlem_TARİHİ', 
  PLN.PAYNO AS 'Ö.D.P.SATIR NO',
  CL.TRANNO AS 'Fiş_No',
  BANK.CODE AS BANKA_KODU,
  BANK.DEFINITION_ AS BANKA,
  HESAP.CODE AS HESAP_KODU,
  HESAP.DEFINITION_ AS HESAP_AÇIKLAMASI,
  CC.CODE AS Öğrenci_No,
  CC.DEFINITION_ AS ÜNVANI,
  PLN.TOTAL AS 'HS.Düşmesi_Gereken',
  CL.AMOUNT AS 'POS_dan_Çekilen'
FROM LG_011_01_PAYTRANS AS PLN 
 JOIN LG_011_BANKACC AS HESAP ON HESAP.LOGICALREF=PLN.BANKACCREF 
 JOIN LG_011_BNCARD AS BANK ON BANK.LOGICALREF = HESAP.BANKREF 
 JOIN LG_011_CLCARD AS CC ON CC.LOGICALREF=PLN.CARDREF 
 LEFT OUTER JOIN LG_011_01_CLFLINE AS CL ON CL.LOGICALREF=PLN.FICHEREF
WHERE PLN.TRCODE=70 AND PLN.DATE_ BETWEEN @Tarih1 AND @Tarih2
Holger Brandt
  • 4,324
  • 1
  • 20
  • 35
  • What database software are you using? You should tag your question accordingly. – HABO Aug 07 '12 at 12:28
  • 1
    Is it possible that something is removing the CRLF at the end of each line? If so, do you have spaces at the end of each line? What happens if you add a `;` after each statement? – James L. Aug 07 '12 at 13:11
  • As you can see, the code, you can place a one-to-one copy and paste and MS SQL Query Analyzer. – Ersoy AYDIN Aug 07 '12 at 13:22
  • This topic is relevant to look at the following link with pictures [link](http://www.logodestek.gen.tr/index.php?topic=11605.new#new) picture file name ileri.jpg – Ersoy AYDIN Aug 07 '12 at 13:26
  • Hi James L.; This is not C # code. This code is a standard T-SQL code as we know it. – Ersoy AYDIN Aug 07 '12 at 13:47
  • The SQL looks like it should run just fine. Can you run SQL Profiler to capture the actual SQL the DBMS is trying to execute and see if it is somehow changed? You can then verify that the SQL you are executing from `Query Analyzer` is identical to the actual SQL that is being run. Or add `select @@spid[CRLF]go` to your query to get your SPID, and then execute `DBCC INPUTBUFFER(SPID)` from another query window (where SPID is the value returned from `select @@spid`). This will show you the last query run on that connection. – James L. Aug 07 '12 at 14:22
  • The system is also connected to the approximately 50 user SQL. Such a situation is also unlikely to extract the error trace with profiler and get. I have no one in the system, it is best to tomorrow morning, let's get a trace. Thank you so much for your suggestions. – Ersoy AYDIN Aug 07 '12 at 14:53

0 Answers0