I want to create a veiw and then select from it in one query, would you please tell me how it is possible the code below:
create view myView as
select [Order Details].Discount from [Order Details]
select * from myView
if i want to run the code, first i have to select that part which is related to creating a view and then i have to select the next part which is related to selecting from that view. i wanted to know the way that both those queries run together when we execute the query the view would be created and then the select executes.
now i want to add that if once i create that veiw the other time SQL gives me error. how can i fix this?? mean that the object will be created just one time
Just write down Go after the command will work for you
you can also use CTE if the view is not necessary