473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to take backup of only the structure of a database in Ms-sql, no need of data.

I need the backup of only the structure of database, not the data.

I tried, this procedure , but it is copying the whole database


create Procedure BackupAlldatabases

as



declare cur_databases cursor for

select name from master..sysdatabases where name not in
('tempdb','master','Northwind','pubs','model','msd b')



open cur_databases



declare @path varchar(100), @DBName varchar(100), @BackupPath
varchar(100), @cleardbs varchar(100),@day varchar(2),@month
varchar(2),@year varchar(4)

set @Path = '\\sdg_bankalert3\BA_Project_BackUp\SDG_BA25'


fetch next from cur_databases into @DBName



While (@@fetch_status = 0)

BEGIN

set @month= Case when len(month(getdate()))=1 then
'0'+Cast(month(getdate()) as varchar) else Cast(month(getdate()) as
varchar) end
set @day=Case when len(day(getdate()))=1 then '0'+Cast(day(getdate()) as
varchar) else Cast(day(getdate()) as varchar) end
set @year=year( GETDATE() )

--set @BackupPath = @Path + '\'+@month+'-'+
@year+'\'+@month+'-'+@day+'-'+ @year+'\'+'sdg_ba25'+'\'+ @DBName + '.bak'
set @BackupPath = @Path + @DBName + '.bak'
print @BackupPath
backup database @DBName to disk = @BackupPath with init

fetch next from cur_databases into @DBName

END



Please if any one can give me the solution...


With regards,
winsletmathew
Nov 3 '08 #1
4 4418
debasisdas
8,127 Expert 4TB
question moved to sql -server forum.
Nov 3 '08 #2
ck9663
2,878 Expert 2GB
If it's SQL 2005, open your Management Studio. Open your Object Explorer Detail window. Click on Tables. Just like Windows Explorer, select all tables that you want to backup. Right-click, Script table as, Create to, New Query Window.

Copy the code on your query window, open a text editor, paste everything.

Happy coding!

-- CK
Nov 4 '08 #3
If it's SQL 2005, open your Management Studio. Open your Object Explorer Detail window. Click on Tables. Just like Windows Explorer, select all tables that you want to backup. Right-click, Script table as, Create to, New Query Window.

Copy the code on your query window, open a text editor, paste everything.

Happy coding!

-- CK

Hello,

The above solution takes a lot of time if if u have many tables..
And if u take many databases , then this process will take a lot of time.

Can u give a command or procedure, which automatically takes the backup of all the structures in the database

With regards,
winsletmathew
Nov 4 '08 #4
ck9663
2,878 Expert 2GB
You can create script to generate structure of each table. The problem is, you will not able to capture the index, constraints, etc.

You can select multiple tables at a time. You just have to browse to other databases.

Maybe our other members can help as well.

-- CK
Nov 4 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: vishal | last post by:
hi i am using mysql as backend. my all tables are of MY ISAM type. so how can i take backup of my tables??????? thxs for your reply................
1
by: Leader | last post by:
Hi, I want to take backup of database logfile periodically and automatically. What should i do then..... Thanks Hoque
0
by: Joachim Klassen | last post by:
Hi all, a db2 database copy which was splitted from the original during suspend mode can be initialized with "db2inidb as standby" and you can run "db2 backup" against that copy (being in...
0
by: Parv | last post by:
hi all can i attach a read only restored database. I restored a database Test in Stand by Mode. After that i detached that database and while restoring i m getting msg "Cannot attach a database...
0
by: egp | last post by:
Hi guys, I have a database using Ms Access 2003 connected to VB6 using ADODB Connection and I want to know how to: - display Ms Access report in VB using VB code then print it out - backup and...
0
by: Dan van Ginhoven | last post by:
Hi! I have DB2 9.1 running on a Linux-server. The database is partioned into two nodes on this server. On another Linux-server, acting as application server, I want to initiate the backup. ...
3
by: sandhu236 | last post by:
Hi all, Can anyone please help me..to take backup automatically from the frontend application (Java swing) after certain number of records REgards, SAndhya
3
by: DALVI PRITAM | last post by:
How to take tables from oracle database
0
by: vijay bharath | last post by:
how to take backup of database using java by query itself? please help
4
by: vidhyaG | last post by:
Hi... i am developing one application in .net... in that i have to take backup the database.and have to restore the Database.... normally we connect the database from file... i tried some...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.