What’s the point to enclose select statements in a transaction?

You’re right: at the standard isolation level, read committed, you do not need to wrap select statements in transactions. Select statements will be protected from dirty reads whether you wrap them in a transaction or not. connection 1: connection 2: begin transaction update user set name=”Bill” where id = 1 select name from users where … Read more

Left join a query with a cross apply

Use OUTER APPLY. Also I’m not sure if the ON clause after the OUTER APPLY is really needed. If the invoiceid is the same coming out as going in then probably not. Select iv.invoiceno, iv.invoiceitem,iv.invoiceno from invoice iv inner join deal d on d.dealid=iv.dealid inner join invoiceitemview ivt on iv.invoiceid=ivt.invoiceid and iv.invoiceno=ivt.invoiceno inner join warehouse … Read more

What is the best practice use of SQL Server T-SQL error handling? [closed]

You should read this: http://www.sommarskog.se/error-handling-I.html I can’t recommend that link highly enough. It’s a bit long, but in a good way. There’s a disclaimer at the front that it was originally written for SQL Server 2000, but it covers the new try/catch error handling abilities in SQL Server 2005+ as well.

Transaction deadlock for select query

My init understanding is that a Select query won’t lock a table, or won’t cause a deadlock This understanding is wrong. SELECT queries take shared locks on the rows they analyze. Shared locks may conflict exclusive locks from update/delete/insert statements. Two SELECT statements are not going to deadlock, but a SELECT can deadlock with an … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)