Using `min_active_rowversion` for global temporary tables The 2019 Stack Overflow Developer Survey Results Are InMySQL Temporary TablesHow to remove Using temporary?Temporary Table error when executing entirety of scriptTemporary Tables With Nonclustered Indexes Including All ColumnsOracle: changing a global temporary table to a normal table and vice versaCreate an explain plan for query over a global temporary tableCan SQL Server Always Encrypted be used for temporary tables?can my SQL Server application code using temporary tables be used for Postgres?MEMORY_OPTIMIZED table as replacement for temporary tablesDoes LocalDB support temporary tables?
Dropping list elements from nested list after evaluation
Why are there uneven bright areas in this photo of black hole?
How to translate "being like"?
Why can't wing-mounted spoilers be used to steepen approaches?
Why isn't the circumferential light around the M87 black hole's event horizon symmetric?
Can withdrawing asylum be illegal?
A word that means fill it to the required quantity
Word to describe a time interval
Geography at the pixel level
What information about me do stores get via my credit card?
Short story: child made less intelligent and less attractive
What is the meaning of Triage in Cybersec world?
What is the motivation for a law requiring 2 parties to consent for recording a conversation
Is an up-to-date browser secure on an out-of-date OS?
Is there a way to generate a uniformly distributed point on a sphere from a fixed amount of random real numbers?
Is it okay to consider publishing in my first year of PhD?
Falsification in Math vs Science
How much of the clove should I use when using big garlic heads?
How do you keep chess fun when your opponent constantly beats you?
Can there be female White Walkers?
Am I ethically obligated to go into work on an off day if the reason is sudden?
How to support a colleague who finds meetings extremely tiring?
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
A female thief is not sold to make restitution -- so what happens instead?
Using `min_active_rowversion` for global temporary tables
The 2019 Stack Overflow Developer Survey Results Are InMySQL Temporary TablesHow to remove Using temporary?Temporary Table error when executing entirety of scriptTemporary Tables With Nonclustered Indexes Including All ColumnsOracle: changing a global temporary table to a normal table and vice versaCreate an explain plan for query over a global temporary tableCan SQL Server Always Encrypted be used for temporary tables?can my SQL Server application code using temporary tables be used for Postgres?MEMORY_OPTIMIZED table as replacement for temporary tablesDoes LocalDB support temporary tables?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I use global temporary tables for easy integration testing of my SQL Server backed application.
But the function min_active_rowversion does not seem to include global temporary tables, like seen here:
using (var connection = new SqlConnection("data source=.;Integrated Security=True"))
connection.Open();
connection.Execute("create table ##mytable ( Id int, rv rowversion )");
var a = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
var x = ToUInt64(connection.Query<byte[]>("insert into ##mytable (Id) output Inserted.rv values (1)").Single()); // => 22647
var b = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
I can't see this limitation documented anywhere. Can this be made to work? And if so, how?
sql-server sql-server-2016 temporary-tables
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
I use global temporary tables for easy integration testing of my SQL Server backed application.
But the function min_active_rowversion does not seem to include global temporary tables, like seen here:
using (var connection = new SqlConnection("data source=.;Integrated Security=True"))
connection.Open();
connection.Execute("create table ##mytable ( Id int, rv rowversion )");
var a = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
var x = ToUInt64(connection.Query<byte[]>("insert into ##mytable (Id) output Inserted.rv values (1)").Single()); // => 22647
var b = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
I can't see this limitation documented anywhere. Can this be made to work? And if so, how?
sql-server sql-server-2016 temporary-tables
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago
add a comment |
I use global temporary tables for easy integration testing of my SQL Server backed application.
But the function min_active_rowversion does not seem to include global temporary tables, like seen here:
using (var connection = new SqlConnection("data source=.;Integrated Security=True"))
connection.Open();
connection.Execute("create table ##mytable ( Id int, rv rowversion )");
var a = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
var x = ToUInt64(connection.Query<byte[]>("insert into ##mytable (Id) output Inserted.rv values (1)").Single()); // => 22647
var b = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
I can't see this limitation documented anywhere. Can this be made to work? And if so, how?
sql-server sql-server-2016 temporary-tables
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I use global temporary tables for easy integration testing of my SQL Server backed application.
But the function min_active_rowversion does not seem to include global temporary tables, like seen here:
using (var connection = new SqlConnection("data source=.;Integrated Security=True"))
connection.Open();
connection.Execute("create table ##mytable ( Id int, rv rowversion )");
var a = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
var x = ToUInt64(connection.Query<byte[]>("insert into ##mytable (Id) output Inserted.rv values (1)").Single()); // => 22647
var b = ToUInt64(connection.Query<byte[]>("select min_active_rowversion()").Single()); // => 20001
I can't see this limitation documented anywhere. Can this be made to work? And if so, how?
sql-server sql-server-2016 temporary-tables
sql-server sql-server-2016 temporary-tables
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 1 hour ago
asgerhallas
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 hour ago
asgerhallasasgerhallas
1585
1585
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asgerhallas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago
add a comment |
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago
add a comment |
1 Answer
1
active
oldest
votes
The explanation would appear to be that the global temporary table is in fact in TempDB, not the database your code is running against. This is because the MIN_ACTIVE_ROWVERSION() function is scoped to the database level.
The min_active_rowversion() function seems to work when you use the following code
USE [db]
CREATE table ##mytable ( Id int, rv rowversion )
USE [tempdb]
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
dbfiddle
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "182"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
asgerhallas is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234637%2fusing-min-active-rowversion-for-global-temporary-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The explanation would appear to be that the global temporary table is in fact in TempDB, not the database your code is running against. This is because the MIN_ACTIVE_ROWVERSION() function is scoped to the database level.
The min_active_rowversion() function seems to work when you use the following code
USE [db]
CREATE table ##mytable ( Id int, rv rowversion )
USE [tempdb]
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
dbfiddle
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
add a comment |
The explanation would appear to be that the global temporary table is in fact in TempDB, not the database your code is running against. This is because the MIN_ACTIVE_ROWVERSION() function is scoped to the database level.
The min_active_rowversion() function seems to work when you use the following code
USE [db]
CREATE table ##mytable ( Id int, rv rowversion )
USE [tempdb]
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
dbfiddle
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
add a comment |
The explanation would appear to be that the global temporary table is in fact in TempDB, not the database your code is running against. This is because the MIN_ACTIVE_ROWVERSION() function is scoped to the database level.
The min_active_rowversion() function seems to work when you use the following code
USE [db]
CREATE table ##mytable ( Id int, rv rowversion )
USE [tempdb]
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
dbfiddle
The explanation would appear to be that the global temporary table is in fact in TempDB, not the database your code is running against. This is because the MIN_ACTIVE_ROWVERSION() function is scoped to the database level.
The min_active_rowversion() function seems to work when you use the following code
USE [db]
CREATE table ##mytable ( Id int, rv rowversion )
USE [tempdb]
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
insert into ##mytable (Id) values (1)
select min_active_rowversion()
dbfiddle
edited 1 hour ago
answered 1 hour ago
George.PalaciosGeorge.Palacios
2,601826
2,601826
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
add a comment |
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
Great, thanks a lot :)
– asgerhallas
1 hour ago
Great, thanks a lot :)
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
And thanks for showing me dbfiddle... really useful.
– asgerhallas
1 hour ago
add a comment |
asgerhallas is a new contributor. Be nice, and check out our Code of Conduct.
asgerhallas is a new contributor. Be nice, and check out our Code of Conduct.
asgerhallas is a new contributor. Be nice, and check out our Code of Conduct.
asgerhallas is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234637%2fusing-min-active-rowversion-for-global-temporary-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Could you add your version of SQL Server as a tag please
– George.Palacios
1 hour ago
@George.Palacios sure! I could go up to SQL Server 2017 too, if needed to make it work.
– asgerhallas
1 hour ago