Showing posts with label situation. Show all posts
Showing posts with label situation. Show all posts

Sunday, March 25, 2012

Backing Up DB & its Permissions

HI All,

I am currently in a situation where I have been fed to the wolves to say the least.

My task is to take the current SQL server 05 we have running on a drive array partioned as C & D and rebuild it.

I need to have the current database backed up, as well as the unique permissions that are currently present on the database.

I then have to remove the hard drives from the RAID array, and replace them with Brand new ones. The OS will then have to be reinstalled, followed by the nessary updates and finally with SQL server.

I then have to import the database back to the new server build w/ the data and the permissions all intact.

Anyone have any idea of how I can go about doing this?

Steve

The permissions on database level are stored inside the database so these will be present once you restore the database.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

When backing up my database and then having to "recompose" it on the new drive arrays, would it be best to copy the DB's by doing an attach / detach, or by simply doing a full backup and then restoring that backup on a clean SQL Server 05 build.

Thanks.

|||

Detach / attach is the easiest way. Restore has the advantage that your backup file will only be as big as the data that is in it.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

To me Detach/Attach or Backup/Restore come out to be about the same, the backup file is smaller, the Detach/Attach seems quicker (no Backup/Restore time). I use a 7zip either way if space or transfer time is an issue.

The main issue I've run into is you have to make sure the Securty IDs (master..syslogins sid) match on the source & destination servers, this isn't an issue for domain logins if you stay within the domain. It's always a concern with SQL logins. The permissions stored in the DB are tied to the user, & the user is tied to the server login via the sid. There are ways to sync them up afterwards, I've had mixed luck there.

HTH,

Roger

|||Because of the login issues that Roger brings up, in this case I would also back up the system databases and restore them on the new system. As long as the version of SQL is the same on both sides, this is the simplest way to make sure that all IDs line up.

Backing Up DB & its Permissions

HI All,

I am currently in a situation where I have been fed to the wolves to say the least.

My task is to take the current SQL server 05 we have running on a drive array partioned as C & D and rebuild it.

I need to have the current database backed up, as well as the unique permissions that are currently present on the database.

I then have to remove the hard drives from the RAID array, and replace them with Brand new ones. The OS will then have to be reinstalled, followed by the nessary updates and finally with SQL server.

I then have to import the database back to the new server build w/ the data and the permissions all intact.

Anyone have any idea of how I can go about doing this?

Steve

The permissions on database level are stored inside the database so these will be present once you restore the database.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

When backing up my database and then having to "recompose" it on the new drive arrays, would it be best to copy the DB's by doing an attach / detach, or by simply doing a full backup and then restoring that backup on a clean SQL Server 05 build.

Thanks.

|||

Detach / attach is the easiest way. Restore has the advantage that your backup file will only be as big as the data that is in it.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

To me Detach/Attach or Backup/Restore come out to be about the same, the backup file is smaller, the Detach/Attach seems quicker (no Backup/Restore time). I use a 7zip either way if space or transfer time is an issue.

The main issue I've run into is you have to make sure the Securty IDs (master..syslogins sid) match on the source & destination servers, this isn't an issue for domain logins if you stay within the domain. It's always a concern with SQL logins. The permissions stored in the DB are tied to the user, & the user is tied to the server login via the sid. There are ways to sync them up afterwards, I've had mixed luck there.

HTH,

Roger

|||Because of the login issues that Roger brings up, in this case I would also back up the system databases and restore them on the new system. As long as the version of SQL is the same on both sides, this is the simplest way to make sure that all IDs line up.sql

Backing Up DB & its Permissions

HI All,

I am currently in a situation where I have been fed to the wolves to say the least.

My task is to take the current SQL server 05 we have running on a drive array partioned as C & D and rebuild it.

I need to have the current database backed up, as well as the unique permissions that are currently present on the database.

I then have to remove the hard drives from the RAID array, and replace them with Brand new ones. The OS will then have to be reinstalled, followed by the nessary updates and finally with SQL server.

I then have to import the database back to the new server build w/ the data and the permissions all intact.

Anyone have any idea of how I can go about doing this?

Steve

The permissions on database level are stored inside the database so these will be present once you restore the database.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

When backing up my database and then having to "recompose" it on the new drive arrays, would it be best to copy the DB's by doing an attach / detach, or by simply doing a full backup and then restoring that backup on a clean SQL Server 05 build.

Thanks.

|||

Detach / attach is the easiest way. Restore has the advantage that your backup file will only be as big as the data that is in it.

WesleyB

Visit my SQL Server weblog @. http://dis4ea.blogspot.com

|||

To me Detach/Attach or Backup/Restore come out to be about the same, the backup file is smaller, the Detach/Attach seems quicker (no Backup/Restore time). I use a 7zip either way if space or transfer time is an issue.

The main issue I've run into is you have to make sure the Securty IDs (master..syslogins sid) match on the source & destination servers, this isn't an issue for domain logins if you stay within the domain. It's always a concern with SQL logins. The permissions stored in the DB are tied to the user, & the user is tied to the server login via the sid. There are ways to sync them up afterwards, I've had mixed luck there.

HTH,

Roger

|||Because of the login issues that Roger brings up, in this case I would also back up the system databases and restore them on the new system. As long as the version of SQL is the same on both sides, this is the simplest way to make sure that all IDs line up.

backing up database

Here is the situation, I have a web application (asp.net/vb.net) with ms sql 2000 as the database. I have two database server. I would like to backup database 1 with database 2. I would like to do it at intervals and through code. If anyone can give me some ideas on how to do this or any research material, please do.

ThanksAnd the copy the stript|||You will need to set up a linked server. You can then run:

EXEC SERVER.master.dbo.xp_executesql @.backup_command

Sunday, February 19, 2012

avoid cursor question

hi how do i avoid using a cursor in this situation.
i want all the payment installment_nos to be ordered by their due dates.
only 'unpaid' payments can be ordered.
/*
drop table payment1
create TABLE payment1
(installment_id integer IDENTITY(1,1), amount float, installment_no int,
due_date datetime, payment_status_code varchar(100))
insert into payment1 (amount, installment_no, due_date,
payment_status_code)
values(1,1,'1-1-05', 'paid')
insert into payment1 (amount, installment_no, due_date,
payment_status_code)
values(1,1,'1-2-05', 'unpaid')
insert into payment1 (amount, installment_no, due_date,
payment_status_code)
values(1,1,'1-3-05', 'unpaid')
insert into payment1 (amount, installment_no, due_date,
payment_status_code)
values(1,1,'1-4-05', 'unpaid')
*/
DECLARE @.liPaymentId integer
DECLARE @.lipaymentCntr integer
/*REORDER installments*/
SET @.lipaymentCntr =1
SELECT @.lipaymentCntr = MAX(installment_no) +1 FROM payment1
WHERE payment_status_code = 'PAID'
IF @.lipaymentCntr IS NULL
SET @.lipaymentCntr =1
DECLARE UpdateCursor CURSOR FOR
SELECT installment_id
FROM payment1
WHERE payment_status_code = 'unpaid'
ORDER by due_date
open UpdateCursor
FETCH NEXT FROM UpdateCursor
INTO @.liPaymentId
WHILE @.@.FETCH_STATUS = 0
BEGIN
UPDATE payment1
SET installment_no = @.lipaymentCntr
WHERE installment_id = @.lipaymentId
SET @.lipaymentCntr = @.lipaymentCntr + 1
FETCH NEXT FROM UpdateCursor
INTO @.lipaymentId
END
CLOSE UpdateCursor
DEALLOCATE UpdateCursor
select * from payment1"ichor" <ichor@.hotmail.com> wrote in message
news:OFkwLY$4FHA.1028@.TK2MSFTNGP11.phx.gbl...
> hi how do i avoid using a cursor in this situation.
> i want all the payment installment_nos to be ordered by their due dates.
> only 'unpaid' payments can be ordered.
> /*
> drop table payment1
> create TABLE payment1
> (installment_id integer IDENTITY(1,1), amount float, installment_no int,
> due_date datetime, payment_status_code varchar(100))
> insert into payment1 (amount, installment_no, due_date,
> payment_status_code)
> values(1,1,'1-1-05', 'paid')
> insert into payment1 (amount, installment_no, due_date,
> payment_status_code)
> values(1,1,'1-2-05', 'unpaid')
> insert into payment1 (amount, installment_no, due_date,
> payment_status_code)
> values(1,1,'1-3-05', 'unpaid')
> insert into payment1 (amount, installment_no, due_date,
> payment_status_code)
> values(1,1,'1-4-05', 'unpaid')
> */
> DECLARE @.liPaymentId integer
> DECLARE @.lipaymentCntr integer
> /*REORDER installments*/
> SET @.lipaymentCntr =1
> SELECT @.lipaymentCntr = MAX(installment_no) +1 FROM payment1
> WHERE payment_status_code = 'PAID'
> IF @.lipaymentCntr IS NULL
> SET @.lipaymentCntr =1
> DECLARE UpdateCursor CURSOR FOR
> SELECT installment_id
> FROM payment1
> WHERE payment_status_code = 'unpaid'
> ORDER by due_date
> open UpdateCursor
> FETCH NEXT FROM UpdateCursor
> INTO @.liPaymentId
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> UPDATE payment1
> SET installment_no = @.lipaymentCntr
> WHERE installment_id = @.lipaymentId
> SET @.lipaymentCntr = @.lipaymentCntr + 1
> FETCH NEXT FROM UpdateCursor
> INTO @.lipaymentId
> END
> CLOSE UpdateCursor
> DEALLOCATE UpdateCursor
>
> select * from payment1
>
Try:
UPDATE payment1
SET installment_no =
(SELECT COUNT(*)
FROM payment1 AS P
WHERE P.due_date <= payment1.due_date
AND P.payment_status_code = 'unpaid')
WHERE payment_status_code = 'unpaid' ;
I'm assuming due_date is unique even though you didn't specify. If not, then
please explain what defines the sequence.
Even better perhaps, avoid putting the redundant installment_no column in
the table at all:
SELECT installment_id, amount,
(SELECT COUNT(*)
FROM payment1 AS P
WHERE P.due_date <=
payment1.due_date
AND P.payment_status_code = 'unpaid') AS installment_no,
due_date, payment_status_code
FROM payment1 ;
David Portas
SQL Server MVP
--|||this is what i actually want
thanks
update payment1
set installment_no =
(select installment_no from payment1 P
where payment_status_code = 'paid'
) +
(select count(*)
FROM payment1 AS P
WHERE P.due_date <= payment1.due_date
AND P.payment_status_code = 'unpaid')
From payment1
WHERE payment_status_code = 'unpaid'
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:xJudnT64sNDwcPLeRVnyvw@.giganews.com...
> "ichor" <ichor@.hotmail.com> wrote in message
> news:OFkwLY$4FHA.1028@.TK2MSFTNGP11.phx.gbl...
> Try:
> UPDATE payment1
> SET installment_no =
> (SELECT COUNT(*)
> FROM payment1 AS P
> WHERE P.due_date <= payment1.due_date
> AND P.payment_status_code = 'unpaid')
> WHERE payment_status_code = 'unpaid' ;
> I'm assuming due_date is unique even though you didn't specify. If not,
> then please explain what defines the sequence.
> Even better perhaps, avoid putting the redundant installment_no column in
> the table at all:
> SELECT installment_id, amount,
> (SELECT COUNT(*)
> FROM payment1 AS P
> WHERE P.due_date <=
> payment1.due_date
> AND P.payment_status_code = 'unpaid') AS installment_no,
> due_date, payment_status_code
> FROM payment1 ;
> --
> David Portas
> SQL Server MVP
> --
>