Truncate_only deprecated in SQL2008 - sql

The following statement
BACKUP LOG [AMS_Prod_log] WITH TRUNCATE_ONLY
works fine in SQL Server 2005 but it doesn't with 2008. It seems truncate_only is deprecated in 2008. Could you please let me know how to achieve this in 2008? What care needs to be taken like backup... etc?

You can backup log to nul device:
BACKUP LOG [databaseName]
TO DISK = 'nul:' WITH STATS = 10
This will mark transaction log as backed-up like TRUNCATE_ONLY option did.
The nul: device is like black hole - so you could not restore from such backup.

This is the list of features depreciated in SQL 2005 i.e. they will not be available in SQL 2008.
http://msdn.microsoft.com/en-us/library/ms143729%28SQL.90%29.aspx
Your alternative is provided in the link.

Related

Database restore seems trigering offline index build

I have a strange behaviour with Sql server 2008 R2 SP2.
First I restore a backup of database.
Then I launch this command
DBCC OPENTRAN
And I get this response:
Transaction information for database 'Pitming'.
Oldest active transaction:
SPID (server process ID): 34s
UID (user ID) : -1
Name : offline index build
LSN : (4082671:527:134)
Start time : Jul 17 2014 8:59:38:107AM
SID : 0x0
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
then it's impossible to delete the database I always get an error saying the database is in use.
It's also impossible to truncate the log
This behaviour is not present in SQL 2005
Any Idea ?
I can't comment until my reputation is higher so forgive me if this "answer" is off the mark. If you are restoring to SQL2008 R2 a backup that was created with an earlier version of SQL Server the problem may be with full-text indexes. If this is the case try setting your server's Full Text Upgrade Option to 1 (Reset) before the restore. Then rebuild the full-text indexes after the database is upgraded to 2008 R2.
http://msdn.microsoft.com/en-us/library/ms186858(v=sql.105).aspx
"After you restore a SQL Server 2005 or SQL Server 2000 database to SQL Server 2008 R2, the database becomes available immediately and is then automatically upgraded. If the database has full-text indexes, the upgrade process either imports, resets, or rebuilds them, depending on the setting of the upgrade_option server property."

How to restore a SQL Backup .bak file on a different (new) server? SQL 2012

I remember myself restoring a db on linux side. I used mysql dump and before I could restore this backup on the other server I had to create a DB with the same name.
Now I am going to switch the server on windows side using SQL 2012. I am backupping many SQL DB's and call them for now db1.bak , db2.bak...
When I now want to restore them on the new server, do I need to create a "structure" first with the same DB names or can I simply restore my DB's with the restore command one by one.
Is there anything else I should prepare? Thanks
A SQL Server database backup contains the structure and the data, so if you have run a full backup on one SQL Server 2012 server, you can restore this onto another SQL Server 2012 + server instance without having to create an empty database first.

How to create a database snapshot in SQL Server 2008 R2

I used the below command to create a database snapshot in SQL Server 2008 R2:
CREATE DATABASE "dbss" ON (
NAME = "os-file-name",
FILENAME = 'path')
AS SNAPSHOT OF "dbName";
GO
I got this error:
Database Snapshot is not supported on Standard Edition (64-bit).
Does anyone knows how can I create a database snapshot in SQL Server 2008 R2?
Database Snapshot is a feature of the Enterprise Edition and the 2008 Developer Edition.
Besides that there is only little use of Snapshots for a "common user". Most things can be done with a backup too.
Main purpose for snapshots are expensive queries on rapidly changing data.
If you got a huge database and need to execute a query for a report that takes some time there is the danger that data may change while the query / procedure fetches data for the report. In this case you need snapshots. There you can query all your data without having problems with changing data.

how to create db back up jobs in sql server 2008?

Microsoft SQL Server 2008 (X64) Microsoft Corporation Developer Edition (64-bit)
i need to create a job for the SQL database to backup everyday
with a different set of new files
i tried doing it and it over rites everyday
i wanted it to create new files everyday...
Plz help me as soon as...
Note:
If i want to create separate folder for each day and stored the back up...
How can i do that plz help me....
If that version include the SQL Agent you can schedule a backup with a SQL script like that:
Edit: corrected code to use dynamic SQL:
declare #sql as nvarchar(1000)
set #sql='BACKUP DATABASE YourDB TO DISK = ''D:\Backups\YourDB-'+convert(char(8),getdate(),112)+'.bak'''
exec sp_executesql #sql
You should be able to do this with a Maintenance Plan and make use of the Back Up Database Task. Taking a look at our backup schedule this generates a new file for the backup each day, with a date and time stamped filename. I believe this is in fact the default and as a consequence for our scenario we also have a cleanup task to delete older backups.
If there is no solution using SSMS, you might try my Powershell script automssqlbackup.

Backup SQL Schema Only?

I need to create a backup of a SQL Server 2005 Database that's only the structure...no records, just the schema. Is there any way to do this?
EDIT: I'm trying to create a backup file to use with old processes, so a script wouldn't work for my purposes, sorry
Use a 3 step process:
Generate a script from the working database
Create a new database from that script
Create a backup of the new database
Why not just use SQL Management Studio to create a complete script of your database and the objects?
Toad for SQL Server does this nicely, if you're considering a commercial product.
I make heavy use of this tool:
SQLBalance for MySQL
Unfortunately; its windows only... but works like a charm to move databases around, data or no data, merge or compare.
As of SQL Server 2012 (patched), you can make a schema only clone of your database using DBCC CLONEDATABASE. Then simply backup the clone.
dbcc clonedatabase(Demo, Demo_Clone) with verify_clonedb;
alter database [Demo_Clone] set read_write;
backup database [Demo_Clone] to disk = N'C:\temp\Demo_SchemaOnly_20220821.bak';
drop database [Demo_Clone];
Read more here: Schema Only Database Backup