June 29, 2010 at 3:10 pm
We need to create a non-logged table. That means that all inserts, deletes, updates to this table should not be logged. Is it possible to do ?
Thanks
June 29, 2010 at 3:12 pm
nope
---------------------------------------------------------------------
June 29, 2010 at 3:13 pm
Any operation that changes a database is logged.
June 29, 2010 at 3:18 pm
i thought table variables were exempt? i know if they are in a transaction, and the transaction is rolled back, the table variable is unaffected...does that mean it's not logged, or just that it doesn't get affected by transactional changes and rollbacks?
Lowell
June 29, 2010 at 3:26 pm
Table variables are not actually database objects, even in tempdb.
# or ## tables are actual tempdb objects, so they are logged.
June 29, 2010 at 3:38 pm
some quick googling highlights this:
http://support.microsoft.com/kb/305977/en-gb
and anyway I have read many times especially on this site that table variables ARE written to tempdb (if not enough memory available). They are also therefore logged in tempdb, but unlike temp tables are not affected by a rollback.
Its all a moot point though, table variables are not the same object type as tables.
---------------------------------------------------------------------
June 29, 2010 at 4:20 pm
I was saying that it is not logged because it is not a database object in tempdb, not because it is not stored in tempdb. The following code shows that a declared table is not actually a db object.
declare @x table (id int not null primary key clustered)
insert into @x (id) select id from tempdb.dbo.sysobjects
declare @y table (xx int not null)
declare @y1 table (xx int not null)
declare @y2 table (xx int not null)
-- Show new objects
select * from tempdb.dbo.sysobjects where id not in (select id from @x)
June 29, 2010 at 10:14 pm
The actual insert/update/delete into a table variable is logged iirc, which makes sense should there be a problem with that transaction during processing you don't necessarily want partial data entered into the table variable.
June 30, 2010 at 1:25 am
Lowell (6/29/2010)
i thought table variables were exempt? i know if they are in a transaction, and the transaction is rolled back, the table variable is unaffected...does that mean it's not logged, or just that it doesn't get affected by transactional changes and rollbacks?
Just that they don't get affected by explicit rollbacks. (ROLLBACK TRANSACTION)
Changes to a table variable still rollback in the case of an error (eg. key violation), and that would not be possible if the table variable was not logged.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 30, 2010 at 1:33 am
Michael Valentine Jones (6/29/2010)
I was saying that it is not logged because it is not a database object in tempdb, not because it is not stored in tempdb. The following code shows that a declared table is not actually a db object.
declare @x table (id int not null primary key clustered)
insert into @x (id) select id from tempdb.dbo.sysobjects
declare @y table (xx int not null)
declare @y1 table (xx int not null)
declare @y2 table (xx int not null)
-- Show new objects
select * from tempdb.dbo.sysobjects where id not in (select id from @x)
They are in tempDb's system tables, the reason that your query isn't showing them is because, as far as I can tell, they're all created before any queries actually run. Try this alternate code, shows up 3 objects and, if you check sys.columns as well, the names match (the object names are mangled, not the column names)
CREATE TABLE #X (id int not null primary key clustered)
insert into #X (id) select id from tempdb.dbo.sysobjects
GO
declare @y table (xx int not null)
declare @y1 table (xx int not null)
declare @y2 table (xx int not null)
-- Show new objects
select * from tempdb.dbo.sysobjects where id not in (select id from #X)
Or:
DECLARE @someTable TABLE (
AReallyLongReallyOddColumnName int
)
SELECT o.*, c.NAME FROM tempdb.sys.objects o INNER JOIN tempdb.sys.columns c ON o.OBJECT_ID = c.object_id
WHERE o.name LIKE '#%'
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 10 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply