I wonder if can I define some parts of the my sql query as a string.
I worked on the code below but I could not manage to concat that pre-defined string part to the existing query.
Actually @sirketid, @uzman, @basvurukodu params works well, however the @ORA_BASVURU_KESIN_KOSUL param is causing a problem.
I think because it has some sql-spesific expression like and, it is treated diffrently than simple variables used for comparison or assigning such as @sirket_id.
It does not throw any error message, the code simply does not excute the operation.
SET @ORA_BASVURU_KESIN_KOSUL = 'and akftif = 1';
UPDATE basvuru 
SET sirket = @sirketid,
    talep_gorevlendirme_rapor = 'G',
    birimi = 'SS', 
    uzman = @uzman,
WHERE
    kod = @basvurukodu + ' ' + @ORA_BASVURU_KESIN_KOSUL; 
Can I concat query parts like this, if so, how?
Thanks
Your query should work like:
EXECof course you have to declare the other variables too:
SET @ORA_BASVURU_KESIN_KOSUL = 'and akftif = 1';
DECLARE @MyExecSQL varchar(2000) =
    'UPDATE basvuru 
        SET sirket = @sirketid
           ,talep_gorevlendirme_rapor = ''G''
           ,birimi = ''SS''
           ,uzman = ' + @uzman + 
     ' WHERE kod = ' + @basvurukodu + 
        ' ' + @ORA_BASVURU_KESIN_KOSUL + ''
;     
EXEC @MyExecSQL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With