Monday, March 26, 2012
HOW TO GET THE PERMISSION ON OBJECTS
We have setup a server with replicaiton which will work as a backup server
now the problem i have is permission on the objects as the same is created a
s
new sql database there are no permission on the objects, I have created the
same roles in the database now i want to give the exactly the same permissio
n
to the roles form the parent server.
Is there any easy way say query which can copy the same permission from the
parent server.
your earlier reply would be a great help.
Thanks and best regards
SharadSELECT
QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)
FROM
INFORMATION_SCHEMA.TABLES
WHERE EXISTS
(
SELECT *
FROM sysindexes
WHERE id =
OBJECT_ID(QUOTENAME(TABLE_SCHEMA) +
N'.' +
QUOTENAME(TABLE_NAME)) AND
indid IN(0,1)
)
"Sharad2005" <niitmalad@.yahoo.co.uk> wrote in message
news:F6C8BE64-0A6D-4BE1-B1EE-E91E8EAB588A@.microsoft.com...
> Dear Friends
> We have setup a server with replicaiton which will work as a backup server
> now the problem i have is permission on the objects as the same is created
as
> new sql database there are no permission on the objects, I have created
the
> same roles in the database now i want to give the exactly the same
permission
> to the roles form the parent server.
> Is there any easy way say query which can copy the same permission from
the
> parent server.
> your earlier reply would be a great help.
> Thanks and best regards
> Sharad
Friday, March 23, 2012
How to get the date of the last backup in SQL
as?If you don't have many tables and you want to keep the added objects added
after the backup, then you can restore the backup to a different database,
then import the data. If you have many tables and not too many objects
added, then it's better to script your added objects, restored the db from
the backup, and added the objects again.
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
quote:
> I would like to get the date of the last database backup using SQL - any
ideas?|||I think this is stored in the MSDB database, poke around and you'll find
some backup history tables.
Mike Kruchten
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
quote:
> I would like to get the date of the last database backup using SQL - any
ideas?|||I think we are at cross purposes here - I just want to be able to get the ca
lendar date that the database was last backed up. You can see this value in
Enterprise Manager by right clicking a database and choosing properties "Las
t database backup: 12/12/20
03 12:01". How can I get this information vis Transact SQL? It must be in so
me table somewhere.|||RESTORE HEADERONLY, see Books Online for detail.
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:78845ADD-4C1B-411C-BE2E-BDFC145FD4F1@.microsoft.com...
quote:
> I think we are at cross purposes here - I just want to be able to get the
calendar date that the database was last backed up. You can see this value
in Enterprise Manager by right clicking a database and choosing properties
"Last database backup: 12/12/2003 12:01". How can I get this information vis
Transact SQL? It must be in some table somewhere.|||Or if you are not looking at the file itself but rather in the database:
use msdb
select max(sjh.run_date) from sysjobhistory sjh
inner join sysjobs sj on sj.job_id = sjh.job_id
inner join sysdbmaintplan_jobs smj on smj.job_id = sj.job_id
inner join sysdbmaintplans sm on sm.plan_id = smj.plan_id
inner join sysdbmaintplan_databases smb on smb.plan_id = sm.plan_id
inner join sysdbmaintplan_history smh on smh.plan_id = sm.plan_id
where sjh.run_status = 1
and smb.database_name = 'yourDBname'
and smh.activity = 'backup database'
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:78845ADD-4C1B-411C-BE2E-BDFC145FD4F1@.microsoft.com...
quote:
> I think we are at cross purposes here - I just want to be able to get the
calendar date that the database was last backed up. You can see this value
in Enterprise Manager by right clicking a database and choosing properties
"Last database backup: 12/12/2003 12:01". How can I get this information vis
Transact SQL? It must be in some table somewhere.|||Thanks, Mike
Your suggestion gets me what I asked for, the date that the database was las
t backed up. Quentin's response gets me what I needed next, the creation dat
e of an actual backup file to make sure that it is the right one. Both very
useful, Thanks.|||Hi,
Please use the below query from QA,
select top 1 database_name,backup_start_date ,backup_finish_date
from msdb..backupset
where database_name='pubs'
order by backup_finish_date desc
Thanks
Hari
MCDBA
"Mike Kruchten" <mkruchten@.fsisolutions.com> wrote in message
news:uJsfwU33DHA.2404@.TK2MSFTNGP12.phx.gbl...
quote:|||Thanks, Hari
> I think this is stored in the MSDB database, poke around and you'll find
> some backup history tables.
> Mike Kruchten
>
> "John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
> news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
> ideas?
>
How to get the date of the last backup in SQL
after the backup, then you can restore the backup to a different database,
then import the data. If you have many tables and not too many objects
added, then it's better to script your added objects, restored the db from
the backup, and added the objects again.
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
> I would like to get the date of the last database backup using SQL - any
ideas?|||I think this is stored in the MSDB database, poke around and you'll find
some backup history tables.
Mike Kruchten
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
> I would like to get the date of the last database backup using SQL - any
ideas?|||I think we are at cross purposes here - I just want to be able to get the calendar date that the database was last backed up. You can see this value in Enterprise Manager by right clicking a database and choosing properties "Last database backup: 12/12/2003 12:01". How can I get this information vis Transact SQL? It must be in some table somewhere.|||RESTORE HEADERONLY, see Books Online for detail.
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:78845ADD-4C1B-411C-BE2E-BDFC145FD4F1@.microsoft.com...
> I think we are at cross purposes here - I just want to be able to get the
calendar date that the database was last backed up. You can see this value
in Enterprise Manager by right clicking a database and choosing properties
"Last database backup: 12/12/2003 12:01". How can I get this information vis
Transact SQL? It must be in some table somewhere.|||Or if you are not looking at the file itself but rather in the database:
use msdb
select max(sjh.run_date) from sysjobhistory sjh
inner join sysjobs sj on sj.job_id = sjh.job_id
inner join sysdbmaintplan_jobs smj on smj.job_id = sj.job_id
inner join sysdbmaintplans sm on sm.plan_id = smj.plan_id
inner join sysdbmaintplan_databases smb on smb.plan_id = sm.plan_id
inner join sysdbmaintplan_history smh on smh.plan_id = sm.plan_id
where sjh.run_status = 1
and smb.database_name = 'yourDBname'
and smh.activity = 'backup database'
"John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
news:78845ADD-4C1B-411C-BE2E-BDFC145FD4F1@.microsoft.com...
> I think we are at cross purposes here - I just want to be able to get the
calendar date that the database was last backed up. You can see this value
in Enterprise Manager by right clicking a database and choosing properties
"Last database backup: 12/12/2003 12:01". How can I get this information vis
Transact SQL? It must be in some table somewhere.|||Thanks, Mik
Your suggestion gets me what I asked for, the date that the database was last backed up. Quentin's response gets me what I needed next, the creation date of an actual backup file to make sure that it is the right one. Both very useful, Thanks.|||Hi,
Please use the below query from QA,
select top 1 database_name,backup_start_date ,backup_finish_date
from msdb..backupset
where database_name='pubs'
order by backup_finish_date desc
Thanks
Hari
MCDBA
"Mike Kruchten" <mkruchten@.fsisolutions.com> wrote in message
news:uJsfwU33DHA.2404@.TK2MSFTNGP12.phx.gbl...
> I think this is stored in the MSDB database, poke around and you'll find
> some backup history tables.
> Mike Kruchten
>
> "John Austin" <John.Austin@.ManagedNewsgroups.com> wrote in message
> news:96C2AEE9-6F5A-4B38-9018-77BE1B28D34F@.microsoft.com...
> > I would like to get the date of the last database backup using SQL - any
> ideas?
>|||Thanks, Hari
Wednesday, March 21, 2012
How to get the database file into .bak file format using C#
Hi,
I want to retrive the values from the database 'northwind' and then i want to store the backup files in"D:/Sample/north_database.bak" format(local machine).
I retrive the database values in .txt,XML format. Now i want to take in .bak format.
give the Suitable solution for this.
Subashini.G
subashi
Check out this article and then download the zip file, to see a sample of the code you want
http://www.codersource.net/csharp_sqldmo_sqlserver.aspx
HTH
|||Hi,
They Above Article is useful for me. But this coding isstored is database Queries in text(txt) format but i need thedatabase table values stored in .bak format.
Give the solution please
|||
subashini
Take 2
Try
http://www.csharphelp.com/archives2/archive345.html
I think this gets you what you need.
HTH
|||Thank you Very Much. This coding is very useful for me.....![]()
Regards
Subashini
Friday, March 9, 2012
How to get Remote Backup
Is there any way that i can get backup from other(Remote) location on LAN
Thanks
You can use Transact-SQL to do this using UNC naming, like this:
RESTORE DATABASE [my_database] FROM DISK = N'\\LanServer\MSSQL\BACKUP\my_database_backup.bak' WITH FILE = 1, NOUNLOAD, STATS = 10
GO
Could you write me source code
Thanks
|||Hi,
you already did this in your other post:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1194939&SiteID=1
BackupDeviceItem bkpDevice = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);
Replace the openBackupDialog.FileName with the UNC name.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
Sir i can use SMO on computer where sql server installed, but when i access sqlserver from other computer (from my client application which i have developed using C#) then i get an exception.
Thanks
|||Which one do you get ? if you want to deploy the application with SMO functionality you will have to package the SMO classes as well.
http://www.microsoft.com/downloads/details.aspx?FamilyID=7A9AD90F-7F95-4369-A206-E84053D63FD3&
HTH, jens K. Suessmeyer.
http://www.sqlserver2005.de|||
when i created setup by default all sqlserver smo dlls were added with setup, and when i installed on other computer following dll were also isntalled with it
Microsoft.SqlServer.BatchParser.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.RegSvrEnum.dll
Microsoft.SqlServer.Replication.dll
Microsoft.SqlServer.Rmo.dll
Microsoft.SqlServer.ServiceBrokerEnum.dll
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.SmoEnum.dll
Microsoft.SqlServer.SqlEnum.dll
Microsoft.SqlServer.WmiEnum.dll
is still i am missing some redistributable
Thanks
|||Which error do you get ?
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||************** Exception Text **************Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server 'xyz,1433'. > Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot open backup device 'C:\Program Files\abcd\Setup1\Backup\asdasd.bak'. Operating system error 3(The system cannot find the path specified.).
BACKUP DATABASE is terminating abnormally.|||YOu will have to aware that the backup file has to be reachable from the relative location of the server NOT the client. If you want to use a backup file on the client you will either have to copy it first to a server-reachable destination OR define the backup path to the client share.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
How to get Remote Backup
Is there any way that i can get backup from other(Remote) location on LAN
Thanks
You can use Transact-SQL to do this using UNC naming, like this:
RESTORE DATABASE [my_database] FROM DISK = N'\\LanServer\MSSQL\BACKUP\my_database_backup.bak' WITH FILE = 1, NOUNLOAD, STATS = 10
GO
Could you write me source code
Thanks
|||Hi,
you already did this in your other post:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1194939&SiteID=1
BackupDeviceItem bkpDevice = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);
Replace the openBackupDialog.FileName with the UNC name.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
Sir i can use SMO on computer where sql server installed, but when i access sqlserver from other computer (from my client application which i have developed using C#) then i get an exception.
Thanks
|||Which one do you get ? if you want to deploy the application with SMO functionality you will have to package the SMO classes as well.
http://www.microsoft.com/downloads/details.aspx?FamilyID=7A9AD90F-7F95-4369-A206-E84053D63FD3&
HTH, jens K. Suessmeyer.
http://www.sqlserver2005.de|||
when i created setup by default all sqlserver smo dlls were added with setup, and when i installed on other computer following dll were also isntalled with it
Microsoft.SqlServer.BatchParser.dll
Microsoft.SqlServer.ConnectionInfo.dll
Microsoft.SqlServer.RegSvrEnum.dll
Microsoft.SqlServer.Replication.dll
Microsoft.SqlServer.Rmo.dll
Microsoft.SqlServer.ServiceBrokerEnum.dll
Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.SmoEnum.dll
Microsoft.SqlServer.SqlEnum.dll
Microsoft.SqlServer.WmiEnum.dll
is still i am missing some redistributable
Thanks
|||Which error do you get ?
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||************** Exception Text **************Microsoft.SqlServer.Management.Smo.FailedOperationException: Backup failed for Server 'xyz,1433'. > Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. > System.Data.SqlClient.SqlException: Cannot open backup device 'C:\Program Files\abcd\Setup1\Backup\asdasd.bak'. Operating system error 3(The system cannot find the path specified.).
BACKUP DATABASE is terminating abnormally.|||YOu will have to aware that the backup file has to be reachable from the relative location of the server NOT the client. If you want to use a backup file on the client you will either have to copy it first to a server-reachable destination OR define the backup path to the client share.
HTH, Jens K. Suessmeyer.
http://www.sqlserver2005.de
Friday, February 24, 2012
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
Tram
Msdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegr oups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get list of backup log files from msdb of standby server?
standby database?
In case of primary server unavailable, I need to get the logfile names
from standby server for disater recovery test.
Thanks in advance
TramMsdb..backupfile gives you a list of data/log files that are backed up.
For logshipping, take a look at msdb..log_shipping_plan_databases.
--
-oj
"tram" <tram_e@.hotmail.com> wrote in message
news:1120079449.879078.169120@.o13g2000cwo.googlegroups.com...
> How do we retrieve log file names of primary backup from msdb of
> standby database?
> In case of primary server unavailable, I need to get the logfile names
> from standby server for disater recovery test.
> Thanks in advance
> Tram
>
How to get last lsn for my DB
To know from which position of this file starting my restore, i need to know
the last lsn point restored on my DB.
while @.id_start < @.id_stop
begin
set @.id_start = @.id_start + 1
RESTORE LOG [MYDB]
FROM DISK = N'Y:\MYDB_LOG'
WITH STANDBY = 'C:\Programmi\Microsoft SQL Server\MSSQL\UNDO_MYDB.ldf',
FILE = @.id_start
if @.@.error > 0
begin
set @.id_stop = 0
BREAK
end
end
I need to know the @.id_start to begin the restore for all backup set missing
.
ThanksHi
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 3, recovery
"checcouno" <checcouno@.discussions.microsoft.com> wrote in message
news:7BF739FD-E00E-4C13-ABDF-75CC564F31CD@.microsoft.com...
> I need to restore multiple set file from a transaction log backup.
> To know from which position of this file starting my restore, i need to
know
> the last lsn point restored on my DB.
>
> while @.id_start < @.id_stop
> begin
> set @.id_start = @.id_start + 1
> RESTORE LOG [MYDB]
> FROM DISK = N'Y:\MYDB_LOG'
> WITH STANDBY = 'C:\Programmi\Microsoft SQL
Server\MSSQL\UNDO_MYDB.ldf',
> FILE = @.id_start
> if @.@.error > 0
> begin
> set @.id_stop = 0
> BREAK
> end
> end
> I need to know the @.id_start to begin the restore for all backup set
missing.
> Thanks