1

Topic: select vs set/values

What it is better, faster, less ?

set @a = 1;
set @b = ' 45646546 ';
set @c = getdate ();

or

select
@a = 1;
@b = ' 45646546 ';
@c = getdate ();
insert tbl (a, b, c) values (@a, @b, @c);

or

insert tbl (a, b, c) select @a, @b, @c;

2

Re: select vs set/values

Prolog;
https://stackoverflow.com/questions/394 … -variables

3

Re: select vs set/values

Tested an example from this article .
If to deduce in Grid single select works more slowly sets set in 2-5 times. :-)))
If to deduce in Text single select works faster sets set in 1.5-2 times, but there were rare occurences, when and hardly more slowly.

4

Re: select vs set/values

Prolog;
You read the link? The main difference in between not in speed, and in that as they work.

5

Re: select vs set/values

Prolog wrote:

That is better, faster, less ?

set @a = 1;
set @b = ' 45646546 ';
set @c = getdate ();

or

select
@a = 1;
@b = ' 45646546 ';
@c = getdate ();
insert tbl (a, b, c) values (@a, @b, @c);

or

insert tbl (a, b, c) select @a, @b, @c;

You  ask:  faster iif or case?
. Similar  will be transformed by the optimizer in "one and too".
If even it "not one and too" microscopic differences of time are not worthy of it that them to study.

6

Re: select vs set/values

aleks222 wrote:

If even it "not one and too" microscopic differences of time are not worthy of it that them to study.

It migrated on 2014-uj and at it
"Noticeable degradation of productivity at passage on 2014"
"Recovered (according to the advice of Microsoft) transfer of a database into compatibility level 2012"
But it would be desirable to leave from 2012, here, now set optimizes also all begins to fly