Is it possible to create transactions in views? e.g.:
CREATE View NewView
AS
BEGIN TRANSACTION
SELECT * FROM TableA
COMMIT
GO
No, it is not possible to use transaction in Views, as Views are for returning rows from one or more tables, they cannot make changes on your tables hence no need for transactions.
You can of course put your SELECT
query in a transaction:
BEGIN TRANSACTION
SELECT * FROM NewView
COMMIT
But this is completely unnecessary. Here you can find some explanations about what transactions are and when to use them:
https://www.mssqltips.com/sqlservertutorial/3304/what-is-a-transaction/
https://www.c-sharpcorner.com/UploadFile/84c85b/understanding-transactions-in-sql-server/