Using SQL Transactions for a single sql query [closed] - sql

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have read a lot about SQL-transaction the pased few days.
But i have not found an answer to my question. So maybe someone here can solve my problem?
The exact question is: Should i use a sql transaction for a single select/update/insert statement?
Or is it to overact to use SQL transactions for a single sql statement?
Thanks...
regards
Ali

Individual statements implicitly have their own transactions. By default, individual statements create and rollback/commit themselves. In theory, you can make it so that it will behave like an explicit transaction, although I can't think of a super great reason to do this. https://learn.microsoft.com/en-us/sql/t-sql/statements/set-implicit-transactions-transact-sql?view=sql-server-2017
The only reason I can think of to wrap an individual statement in its own explicit transaction is if you wanted to leave the transaction open so you could test something like blocking, or just maybe check the data while debugging before rolling it back.

Related

how to know internal mechanism of join in sql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am curious if one can see the internal mechanism of merge join or any other join sql?
For Oracle have a look at this document: Database SQL Tuning Guide - Joins
If you are thinking about how they work, you can look it up here, it's a great representation of it.
If you are thinking about the code behind it, I think you'll have to work for MS to access it ;)

Differences between SAS and SQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Can anyone articulate what the key differences are between SAS and SQL? I haven't worked much with SAS but went on a weeks training course, and basically it seemed like the equivalent but more convoluted and was able to do graphs.
Would appreciate some key bullet differences between them.
Standard SQL is a language to query, manipulate and define data in any(!) database. It is like the "latin language" of DB systems. Everyone knows it in order to perform standard tasks. SAS is like an extension to that with many functions.
I found a good document:
http://www.sascommunity.org/mwiki/images/5/52/CMSSUG-0506-SQL.pdf

Increment counter or query relations? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Let's say I have a User model and a Favorite model. I want to know how many favorites a user has.
I see that you can accomplish this in two ways.
Atomically increment a counter attribute on the user model when a favorite is created. Access using user_instance.favorite_count
Query the favorite count for the user: user_instance.favorite_set.count()
I would imagine that as the DB grows, counting becomes more expensive.
Which implementation is more scalable?
I smell some premature optimization here. Databases are extremely good at counting things. Unless you have measured and are seeing some identifiable slowness, you should not attempt to denormalize: it is difficult to get right and always at risk of getting out of sync. Go with the query; and don't forget you can use aggregation to query the counts for a queryset of users at one time.

What can not be done / which results are impossible to show using SQL? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I would like to know if there is any problem or any sort of combinations that can not be solved using SQL language.
Is there any list in the web where I can find situations that are impossible to measure using SQL?
Or is everything possible to calculate using SQL.
Thank you.
SQL is pretty flexible, but it can't do everything. However there is no handy guide that I know of that lists what it can't do. There are things that I think you can do but shouldn't: anything that involves doing calculations one row at a time are very inefficient and will generally be faster if done in code.

powershell multi valued variables or sql table [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
i'm wanting to write data into memory only for a temp time. the format is essentially the same as an sql table with say 5 columns and 1,000 rows, give or take. simply i want to store this data and run queries against it to make calculations, sorting it, querying it to then produce chart reports and excel data.
I looked at custom psobjects and then sql and i can't see why i'd use custom psobjects over sql, what do you think?
I also couldn't see that adding multiple rows as such, using psobjects was as straight forward as adding another row in sql.
thanks
steve
I guess it depends on what you're more comfortable with, but if you're going to do it in Powershell then using PS custom objects seems like a logical choice since the cmdlets were designed to work with those.