Does LocalDB support temporary tables?
Are SQL Server temporary tables (prefixed with #) supported in LocalDB instances?
sql-server t-sql tempdb temporary-tables sql-server-localdb
New contributor
user3424480 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 |
Are SQL Server temporary tables (prefixed with #) supported in LocalDB instances?
sql-server t-sql tempdb temporary-tables sql-server-localdb
New contributor
user3424480 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 |
Are SQL Server temporary tables (prefixed with #) supported in LocalDB instances?
sql-server t-sql tempdb temporary-tables sql-server-localdb
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Are SQL Server temporary tables (prefixed with #) supported in LocalDB instances?
sql-server t-sql tempdb temporary-tables sql-server-localdb
sql-server t-sql tempdb temporary-tables sql-server-localdb
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 18 hours ago
Solomon Rutzky
47.6k579172
47.6k579172
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 22 hours ago
user3424480user3424480
341
341
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
user3424480 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
user3424480 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 |
add a comment |
4 Answers
4
active
oldest
votes
I can't answer for all versions, but for SQL Server 2012 up until SQL Server 2017 I am certain that they are supported
LocalDB has the same programmability features as SQL Server Express.
SQL Server Express LocalDB, a lightweight version of Express that has
all of its programmability features, yet runs in user mode and has a
fast, zero-configuration installation and a short list of
prerequisites.
Source
And then, building on the previous point, for the SQL Server express 2012 T-SQL Syntax
Express supports the same T-SQL language elements you find in any
edition of SQL Server. Not only can you issue data manipulation
language queries against the database, but you can also run data
definition language statements to create such objects as views,
triggers, cursors and stored procedures
Source
Testing (SQL Server 2017)

USE testdb
GO
CREATE TABLE #temp (id int , value nvarchar(255));
INSERT INTO #temp( id ,value)
SELECT 5, 'bla';
SELECT * FROM #temp;
result
id value
5 bla
The temporary table also works when changing the db's compatibility mode to 100 (2008).
add a comment |
Yes, all forms of temporary objects (local temp tables, global temp tables, table variables, local temp stored procedures, and global temp stored procedures) are available in all versions of SQL Server Express LocalDB.
I have executed the following simple test of each of those 5 objects types across versions 2012, 2014, 2016, and 2017 and received no errors.
CREATE TABLE #LocalTempTable (Col1 INT);
SELECT * FROM #LocalTempTable;
CREATE TABLE ##GlobalTempTable (Col1 INT);
SELECT * FROM ##GlobalTempTable;
DECLARE @TableVariable TABLE (Col1 INT);
SELECT * FROM @TableVariable;
GO
CREATE PROCEDURE #LocalTempProc
AS
SELECT 1;
GO
EXEC #LocalTempProc;
GO
CREATE PROCEDURE ##GlobalTempProc
AS
SELECT 2;
GO
EXEC ##GlobalTempProc;
Also, SQL Server would likely not even start up if these were not available as they are used in system stored procedures, features found in msdb, etc.
add a comment |
Yes, Localdb supports temporay tables.
USE [test];
GO
CREATE TABLE #mytemp
(
id int,
foo int,
bar int
);
GO
SELECT
*
FROM
tempdb.INFORMATION_SCHEMA.TABLES;
GO
DROP TABLE #mytemp;
GO
Returns:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------- ---------------- ------------------------------------ ----------
tempdb dbo #mytemp________________00000000000A BASE TABLE
And querying sys.databases:
SELECT
name,
database_id
FROM
sys.databases;
returns same system databases structure.
name database_id
--------- -----------
master 1
tempdb 2
model 3
msdb 4
test 5
add a comment |
Agree with @RandiVertongen.
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
For more information on LocalDB refer official link source
Note it has restrictions:
1) LocalDB cannot be a merge replication subscriber.
2) LocalDB does not support FILESTREAM.
3) LocalDB only allows local queues for Service Broker.
4) An instance of LocalDB owned by the built-in accounts such as NT AUTHORITYSYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.
I hope this helps!
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
});
}
});
user3424480 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%2f226792%2fdoes-localdb-support-temporary-tables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I can't answer for all versions, but for SQL Server 2012 up until SQL Server 2017 I am certain that they are supported
LocalDB has the same programmability features as SQL Server Express.
SQL Server Express LocalDB, a lightweight version of Express that has
all of its programmability features, yet runs in user mode and has a
fast, zero-configuration installation and a short list of
prerequisites.
Source
And then, building on the previous point, for the SQL Server express 2012 T-SQL Syntax
Express supports the same T-SQL language elements you find in any
edition of SQL Server. Not only can you issue data manipulation
language queries against the database, but you can also run data
definition language statements to create such objects as views,
triggers, cursors and stored procedures
Source
Testing (SQL Server 2017)

USE testdb
GO
CREATE TABLE #temp (id int , value nvarchar(255));
INSERT INTO #temp( id ,value)
SELECT 5, 'bla';
SELECT * FROM #temp;
result
id value
5 bla
The temporary table also works when changing the db's compatibility mode to 100 (2008).
add a comment |
I can't answer for all versions, but for SQL Server 2012 up until SQL Server 2017 I am certain that they are supported
LocalDB has the same programmability features as SQL Server Express.
SQL Server Express LocalDB, a lightweight version of Express that has
all of its programmability features, yet runs in user mode and has a
fast, zero-configuration installation and a short list of
prerequisites.
Source
And then, building on the previous point, for the SQL Server express 2012 T-SQL Syntax
Express supports the same T-SQL language elements you find in any
edition of SQL Server. Not only can you issue data manipulation
language queries against the database, but you can also run data
definition language statements to create such objects as views,
triggers, cursors and stored procedures
Source
Testing (SQL Server 2017)

USE testdb
GO
CREATE TABLE #temp (id int , value nvarchar(255));
INSERT INTO #temp( id ,value)
SELECT 5, 'bla';
SELECT * FROM #temp;
result
id value
5 bla
The temporary table also works when changing the db's compatibility mode to 100 (2008).
add a comment |
I can't answer for all versions, but for SQL Server 2012 up until SQL Server 2017 I am certain that they are supported
LocalDB has the same programmability features as SQL Server Express.
SQL Server Express LocalDB, a lightweight version of Express that has
all of its programmability features, yet runs in user mode and has a
fast, zero-configuration installation and a short list of
prerequisites.
Source
And then, building on the previous point, for the SQL Server express 2012 T-SQL Syntax
Express supports the same T-SQL language elements you find in any
edition of SQL Server. Not only can you issue data manipulation
language queries against the database, but you can also run data
definition language statements to create such objects as views,
triggers, cursors and stored procedures
Source
Testing (SQL Server 2017)

USE testdb
GO
CREATE TABLE #temp (id int , value nvarchar(255));
INSERT INTO #temp( id ,value)
SELECT 5, 'bla';
SELECT * FROM #temp;
result
id value
5 bla
The temporary table also works when changing the db's compatibility mode to 100 (2008).
I can't answer for all versions, but for SQL Server 2012 up until SQL Server 2017 I am certain that they are supported
LocalDB has the same programmability features as SQL Server Express.
SQL Server Express LocalDB, a lightweight version of Express that has
all of its programmability features, yet runs in user mode and has a
fast, zero-configuration installation and a short list of
prerequisites.
Source
And then, building on the previous point, for the SQL Server express 2012 T-SQL Syntax
Express supports the same T-SQL language elements you find in any
edition of SQL Server. Not only can you issue data manipulation
language queries against the database, but you can also run data
definition language statements to create such objects as views,
triggers, cursors and stored procedures
Source
Testing (SQL Server 2017)

USE testdb
GO
CREATE TABLE #temp (id int , value nvarchar(255));
INSERT INTO #temp( id ,value)
SELECT 5, 'bla';
SELECT * FROM #temp;
result
id value
5 bla
The temporary table also works when changing the db's compatibility mode to 100 (2008).
edited 22 hours ago
answered 22 hours ago
Randi VertongenRandi Vertongen
1,512313
1,512313
add a comment |
add a comment |
Yes, all forms of temporary objects (local temp tables, global temp tables, table variables, local temp stored procedures, and global temp stored procedures) are available in all versions of SQL Server Express LocalDB.
I have executed the following simple test of each of those 5 objects types across versions 2012, 2014, 2016, and 2017 and received no errors.
CREATE TABLE #LocalTempTable (Col1 INT);
SELECT * FROM #LocalTempTable;
CREATE TABLE ##GlobalTempTable (Col1 INT);
SELECT * FROM ##GlobalTempTable;
DECLARE @TableVariable TABLE (Col1 INT);
SELECT * FROM @TableVariable;
GO
CREATE PROCEDURE #LocalTempProc
AS
SELECT 1;
GO
EXEC #LocalTempProc;
GO
CREATE PROCEDURE ##GlobalTempProc
AS
SELECT 2;
GO
EXEC ##GlobalTempProc;
Also, SQL Server would likely not even start up if these were not available as they are used in system stored procedures, features found in msdb, etc.
add a comment |
Yes, all forms of temporary objects (local temp tables, global temp tables, table variables, local temp stored procedures, and global temp stored procedures) are available in all versions of SQL Server Express LocalDB.
I have executed the following simple test of each of those 5 objects types across versions 2012, 2014, 2016, and 2017 and received no errors.
CREATE TABLE #LocalTempTable (Col1 INT);
SELECT * FROM #LocalTempTable;
CREATE TABLE ##GlobalTempTable (Col1 INT);
SELECT * FROM ##GlobalTempTable;
DECLARE @TableVariable TABLE (Col1 INT);
SELECT * FROM @TableVariable;
GO
CREATE PROCEDURE #LocalTempProc
AS
SELECT 1;
GO
EXEC #LocalTempProc;
GO
CREATE PROCEDURE ##GlobalTempProc
AS
SELECT 2;
GO
EXEC ##GlobalTempProc;
Also, SQL Server would likely not even start up if these were not available as they are used in system stored procedures, features found in msdb, etc.
add a comment |
Yes, all forms of temporary objects (local temp tables, global temp tables, table variables, local temp stored procedures, and global temp stored procedures) are available in all versions of SQL Server Express LocalDB.
I have executed the following simple test of each of those 5 objects types across versions 2012, 2014, 2016, and 2017 and received no errors.
CREATE TABLE #LocalTempTable (Col1 INT);
SELECT * FROM #LocalTempTable;
CREATE TABLE ##GlobalTempTable (Col1 INT);
SELECT * FROM ##GlobalTempTable;
DECLARE @TableVariable TABLE (Col1 INT);
SELECT * FROM @TableVariable;
GO
CREATE PROCEDURE #LocalTempProc
AS
SELECT 1;
GO
EXEC #LocalTempProc;
GO
CREATE PROCEDURE ##GlobalTempProc
AS
SELECT 2;
GO
EXEC ##GlobalTempProc;
Also, SQL Server would likely not even start up if these were not available as they are used in system stored procedures, features found in msdb, etc.
Yes, all forms of temporary objects (local temp tables, global temp tables, table variables, local temp stored procedures, and global temp stored procedures) are available in all versions of SQL Server Express LocalDB.
I have executed the following simple test of each of those 5 objects types across versions 2012, 2014, 2016, and 2017 and received no errors.
CREATE TABLE #LocalTempTable (Col1 INT);
SELECT * FROM #LocalTempTable;
CREATE TABLE ##GlobalTempTable (Col1 INT);
SELECT * FROM ##GlobalTempTable;
DECLARE @TableVariable TABLE (Col1 INT);
SELECT * FROM @TableVariable;
GO
CREATE PROCEDURE #LocalTempProc
AS
SELECT 1;
GO
EXEC #LocalTempProc;
GO
CREATE PROCEDURE ##GlobalTempProc
AS
SELECT 2;
GO
EXEC ##GlobalTempProc;
Also, SQL Server would likely not even start up if these were not available as they are used in system stored procedures, features found in msdb, etc.
answered 19 hours ago
Solomon RutzkySolomon Rutzky
47.6k579172
47.6k579172
add a comment |
add a comment |
Yes, Localdb supports temporay tables.
USE [test];
GO
CREATE TABLE #mytemp
(
id int,
foo int,
bar int
);
GO
SELECT
*
FROM
tempdb.INFORMATION_SCHEMA.TABLES;
GO
DROP TABLE #mytemp;
GO
Returns:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------- ---------------- ------------------------------------ ----------
tempdb dbo #mytemp________________00000000000A BASE TABLE
And querying sys.databases:
SELECT
name,
database_id
FROM
sys.databases;
returns same system databases structure.
name database_id
--------- -----------
master 1
tempdb 2
model 3
msdb 4
test 5
add a comment |
Yes, Localdb supports temporay tables.
USE [test];
GO
CREATE TABLE #mytemp
(
id int,
foo int,
bar int
);
GO
SELECT
*
FROM
tempdb.INFORMATION_SCHEMA.TABLES;
GO
DROP TABLE #mytemp;
GO
Returns:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------- ---------------- ------------------------------------ ----------
tempdb dbo #mytemp________________00000000000A BASE TABLE
And querying sys.databases:
SELECT
name,
database_id
FROM
sys.databases;
returns same system databases structure.
name database_id
--------- -----------
master 1
tempdb 2
model 3
msdb 4
test 5
add a comment |
Yes, Localdb supports temporay tables.
USE [test];
GO
CREATE TABLE #mytemp
(
id int,
foo int,
bar int
);
GO
SELECT
*
FROM
tempdb.INFORMATION_SCHEMA.TABLES;
GO
DROP TABLE #mytemp;
GO
Returns:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------- ---------------- ------------------------------------ ----------
tempdb dbo #mytemp________________00000000000A BASE TABLE
And querying sys.databases:
SELECT
name,
database_id
FROM
sys.databases;
returns same system databases structure.
name database_id
--------- -----------
master 1
tempdb 2
model 3
msdb 4
test 5
Yes, Localdb supports temporay tables.
USE [test];
GO
CREATE TABLE #mytemp
(
id int,
foo int,
bar int
);
GO
SELECT
*
FROM
tempdb.INFORMATION_SCHEMA.TABLES;
GO
DROP TABLE #mytemp;
GO
Returns:
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE
---------------- ---------------- ------------------------------------ ----------
tempdb dbo #mytemp________________00000000000A BASE TABLE
And querying sys.databases:
SELECT
name,
database_id
FROM
sys.databases;
returns same system databases structure.
name database_id
--------- -----------
master 1
tempdb 2
model 3
msdb 4
test 5
answered 21 hours ago
McNetsMcNets
15.1k41858
15.1k41858
add a comment |
add a comment |
Agree with @RandiVertongen.
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
For more information on LocalDB refer official link source
Note it has restrictions:
1) LocalDB cannot be a merge replication subscriber.
2) LocalDB does not support FILESTREAM.
3) LocalDB only allows local queues for Service Broker.
4) An instance of LocalDB owned by the built-in accounts such as NT AUTHORITYSYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.
I hope this helps!
add a comment |
Agree with @RandiVertongen.
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
For more information on LocalDB refer official link source
Note it has restrictions:
1) LocalDB cannot be a merge replication subscriber.
2) LocalDB does not support FILESTREAM.
3) LocalDB only allows local queues for Service Broker.
4) An instance of LocalDB owned by the built-in accounts such as NT AUTHORITYSYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.
I hope this helps!
add a comment |
Agree with @RandiVertongen.
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
For more information on LocalDB refer official link source
Note it has restrictions:
1) LocalDB cannot be a merge replication subscriber.
2) LocalDB does not support FILESTREAM.
3) LocalDB only allows local queues for Service Broker.
4) An instance of LocalDB owned by the built-in accounts such as NT AUTHORITYSYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.
I hope this helps!
Agree with @RandiVertongen.
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When connecting, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
For more information on LocalDB refer official link source
Note it has restrictions:
1) LocalDB cannot be a merge replication subscriber.
2) LocalDB does not support FILESTREAM.
3) LocalDB only allows local queues for Service Broker.
4) An instance of LocalDB owned by the built-in accounts such as NT AUTHORITYSYSTEM can have manageability issues due to windows file system redirection; Instead use a normal windows account as the owner.
I hope this helps!
answered 22 hours ago
MarmiKMarmiK
237111
237111
add a comment |
add a comment |
user3424480 is a new contributor. Be nice, and check out our Code of Conduct.
user3424480 is a new contributor. Be nice, and check out our Code of Conduct.
user3424480 is a new contributor. Be nice, and check out our Code of Conduct.
user3424480 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%2f226792%2fdoes-localdb-support-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