SQL Query Declaration problem I have a view as shown below.The View is good running.When I attempt to run view,I got the following the error.What might the problem?

Incorrect syntax near the keyword 'Declare'


SQL Query:

create View [dbo].StokMaliyet
AS
Declare @Dolar decimal(18,3),@Euro decimal(18,3)

set @Dolar=(select Dolar from GunlukDoviz
set @Euro=(select Euro from GunlukDoviz)

 select Stok_Kodu,
 (case
 when dovtip='3' then net_maliyet
 when dovtip='2' then ((net_maliyet)*@Dolar)/@Euro
 When dovtip='0' then (net_maliyet)/@Euro
 end )  as Maliyet
 from ib_mlyt
You cannot use declare and any code manipulation in view (select statement ONLY at SQL Server of course). 

CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ] 
[ WITH &lt;view_attribute&gt; [ ,...n ] ] 
AS select_statement 
[ WITH CHECK OPTION ] [ ; ]

&lt;view_attribute&gt; ::= 
{
    [ ENCRYPTION ]
    [ SCHEMABINDING ]
    [ VIEW_METADATA ]     } 


See for more details

Use stored procedure instead of view