views:

78

answers:

2

When I'm running this query on my page, I'm getting a

Subqueries are not allowed in this context. Only scalar expressions are allowed

error. What am I doing wrong?

insert into Konular(KonuAd, AltKategoriID, KategoriID, KonuSahibi,GönderenID, İçerik,KonuTarih,SonMesajTarihi) 
values(@Başlık,'184','0',@KonuSahibi,'27',@İçerik,'04.09.2010 08:35:19',(select convert(datetime,'04.09.2010 08:35:19',104)))
+3  A: 

You're using a subquery in a context where only scalar expressions are allowed :-)

You don't need the select. Try:

insert into Konular(KonuAd, AltKategoriID, KategoriID, KonuSahibi,GönderenID, İçerik,KonuTarih,SonMesajTarihi) 
values(@Başlık,'184','0',@KonuSahibi,'27',@İçerik,'04.09.2010 08:35:19', convert(datetime,'04.09.2010 08:35:19',104))
Michael Petrotta
I will consider " Select " on every query now thanks :)
Ümit Akkaya
+2  A: 

Remove (select ), because its a subquery and its not allowed.

values(@Başlık,'184','0',@KonuSahibi,'27',@İçerik,'04.09.2010 08:35:19', cast( '04.09.2010 08:35:19' AS datetime )
cichy
This worked also, and i learned a new thing like " cast " thanks to you :)
Ümit Akkaya