Showing posts with label environment. Show all posts
Showing posts with label environment. Show all posts

Friday, March 23, 2012

How can i back-up my database in production environment.

I developed an asp.net application in visual web developer 2005 express edition and SQL sever 2005 express with Advanced services. The application has been deployed and iam wondering what tools are availabel to for backing up my data. Are there any tools i can use to back-up my database. Iam not talking of third party tools but tools a vailable in sql sever 2005 express with advanced services or visual web developer express.

OR can write a vb.net Sub procedure that i run and have my database backed up. If so where can i start or what other options may i explorer.

Hi Dear,

you can backup your datbase by usingMicrosoft SQL Server Management Studio and also by ur VB.NET application

i will try to explain you both ways.

1:By using Microsoft SQL Server Management Studio

Open Management Studio and Right Click On Your Database and go to the Tasks->Backup menu item, Backup Database Dialogbox will be open.

Click Add button in Destination Panel, and choose the Destination File. and simply press OK ( This is the simplest way, but you can customize your backup by choosing different options available on Backup Database Dialog)

2. By VB.NET Application

execute following TSQL statement in your SQL Server

USE

master

EXEC

sp_addumpdevice'disk','MyDataBaseBackup','c:\YourDatabaseBackupDirectory\MyDBBackup.dat'

' and then use following code in your application

' VB.NET Code

Dim conAsNew SqlConnection("ConnectionString")Dim comAsNew SqlCommand("BACKUP DATABASE YourDataBaseName TO MyDataBaseBackup")

com.Connection = con

com.Connection.Open()

com.ExecuteNonQuery()

com.Connection.Close()

Thanks

Regards,

Muhammad Akhtar Shiekh

|||

Oh thanks very much Akhtar,

I want to take on and understand thoroughly the second option(vb.net option) as its looks to be more flexible though a bit complicated. Looks like i have to start with stored procedures, isn't. Please would you point me to a tutorial from microsoft to get me started with the core basics of backingup a database using this approach.

Thanks very much.

|||Check out the BACKUP statement in Books On Line. You might want to schedule it as a job and include it in your weekly maintenance window (if you dont already have one, time to create one) rather than create a VB application for it.|||

The problem all starts with version of sql sever one is using. some of the documentation do not apply to the express version of sql sever so you find your self wasting valuable time reading an article that you later find out does not apply to the product version your running. Iam running sql sever 2005 express edition with advanced sevices in my case.

sql

Monday, March 19, 2012

How can db_owner restore db from backup and keep his permissions?

Hi there
I'm developing an application, and from time to time I take it to
production environment and keep it up to date with dev version. When I
tried to do this alone (istead of sysadmin) I got some error saying
that I didn't have enough permissions to do restore (despite I was a
db_owner).
Is it possible, that the reason for that is the fact that in dev
version which I was restoring there was no user which had db_owner
permissions? so, I was working on this database as some user with
db_owner permissions and restored it to the state in which there wasn't
any user mapped to my login in db anymore.
Is it possible? If so, then how can I restore db as a db_owner?
thanks a lot
HPFrom BOL:
"If the database being restored does not exist, the user must have CREATE
DATABASE permissions to be able to execute RESTORE. If the database exists,
RESTORE permissions default to members of the sysadmin and dbcreator fixed
server roles and the owner (dbo) of the database (for the FROM
DATABASE_SNAPSHOT option, the database always exists)."
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

How can db_owner restore db from backup and keep his permissions?

Hi there
I'm developing an application, and from time to time I take it to
production environment and keep it up to date with dev version. When I
tried to do this alone (istead of sysadmin) I got some error saying
that I didn't have enough permissions to do restore (despite I was a
db_owner).
Is it possible, that the reason for that is the fact that in dev
version which I was restoring there was no user which had db_owner
permissions? so, I was working on this database as some user with
db_owner permissions and restored it to the state in which there wasn't
any user mapped to my login in db anymore.
Is it possible? If so, then how can I restore db as a db_owner?
thanks a lot
HP
From BOL:
"If the database being restored does not exist, the user must have CREATE
DATABASE permissions to be able to execute RESTORE. If the database exists,
RESTORE permissions default to members of the sysadmin and dbcreator fixed
server roles and the owner (dbo) of the database (for the FROM
DATABASE_SNAPSHOT option, the database always exists)."
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

How can db_owner restore db from backup and keep his permissions?

Hi there
I'm developing an application, and from time to time I take it to
production environment and keep it up to date with dev version. When I
tried to do this alone (istead of sysadmin) I got some error saying
that I didn't have enough permissions to do restore (despite I was a
db_owner).
Is it possible, that the reason for that is the fact that in dev
version which I was restoring there was no user which had db_owner
permissions? so, I was working on this database as some user with
db_owner permissions and restored it to the state in which there wasn't
any user mapped to my login in db anymore.
Is it possible? If so, then how can I restore db as a db_owner?
thanks a lot
HPFrom BOL:
"If the database being restored does not exist, the user must have CREATE
DATABASE permissions to be able to execute RESTORE. If the database exists,
RESTORE permissions default to members of the sysadmin and dbcreator fixed
server roles and the owner (dbo) of the database (for the FROM
DATABASE_SNAPSHOT option, the database always exists)."
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .

Monday, March 12, 2012

how best to tackle logins with SQL authentication after automatic failover

In an sql authentication environment with an automatic failover in database mirroring how to you manage new logins which have been created on the principle since the start of mirroring? Since the master cannot be mirrored, and the mirror database cannot be read during mirroring (except as a snapshot) in order to find the missing logins, I assume that only after failover a script should run to create the new logins and then run sp_change_users_login . The qestions are:

1) should the script create a new login first and then run sp_change_users_login with option update_one , or should sp_change_users_login using option

Auto_Fix create the missing logins?

2) But what is the password of these users? is it initially NULL , as a consequence of sp_change_users_login? What about the SIDs?

3) Or should we bypass sp_change_users_login altogether and use

CREATE LOGIN <loginname> WITH PASSWORD = <password>, SID = <sid for same login on principal server>,...as described in http://blogs.msdn.com/chadboyd/archive/2007/01/05/login-failures-connecting-to-new-principal-after-failover-using-database-mirroring.aspx

4) What is the event that would trigger this script to run after the aitomatic failover ?

Is there a definitive MIcrosoft agreed apon and recommended method to tackle this?

If you want your application users to connect after failover you better create those logins beforehand @. both the principal and @. mirror server @. the time of configuring mirroring so that they will be available to you but will be mismatched and after failover you can correct them using sp_change_users_login sp.

and for the less important ones you can make use of SSIS to transfer logins frequently so that after failover you can just restore the master syslogins table or master db and fix the mismatch by change users login sp......

|||

Thank you for your anwer. My question was about the new logins created after mirroring had begun. Of course before mirroring started the existing logins were recreated on the mirrorserver beforehand . The question was whether sp_change_users_login should be used with update_one or Auto_Fix or not used at all . The auto fix option creates a login if there isn't one. The update_one option does not .

Assuming rhat SSIS would transfer the new logins from the princiopal master to the mirror master while database mirroring would transfer the users from the principal to the mirror. Will the SIDs be in order? If a script has to be run it would have to be run automatically so what is the trigger that this script will be triggered by?

|||

Actually there are a few issues here:

Firstly SSIS will not help you because as of 2005 the Transfer Logins task does not transfer the passwords, it resets the passwords which to be honest wouldn't help especially if you are using the High Availability option.

Next, you need to take care of the SID's otherwise you will have to sync them. See this KB article

Lastly, In 2005 you cannot create a login which has a default database that is offline. So if an app needs to use Automatic Client Redirect in a High Availability setup and the account is created on the Principal after mirroring has been configured, you will not be able to add the login on the Mirror. The only workaround is to bring the mirror online periodically and sync the logins. I heard it may be fixed in 2008 however; I have not tried yet, maybe someone can clarify for me.

Sunday, February 19, 2012

Hosting Environment - Advice please

(Please forgive me for cross posting on this one)
I am attemptign to offer some kind of hosting of SQL databases as an add-on
to a Web Platform i have built. Unfortunately my SQL knowlwedge is a little
short of l33t.
My question is this:
Is it better to write a web front end to allow the customer to adminsiter
their databases, or to allwo them access to Enterprise manager, from where
they can administer their databases.
thanks
Martin[dot]Christopher[at]uk[dot]easynet[dot]netI think it's a bit risky to give folks access to Enterprise manager, and
it's not usually the done thing. By using a tool you develop you can control
exactly what the customer can do.
"Martin c" <martin@.nospam.com> wrote in message
news:eINWglQfDHA.1888@.TK2MSFTNGP12.phx.gbl...
> (Please forgive me for cross posting on this one)
> I am attemptign to offer some kind of hosting of SQL databases as an
add-on
> to a Web Platform i have built. Unfortunately my SQL knowlwedge is a
little
> short of l33t.
> My question is this:
> Is it better to write a web front end to allow the customer to adminsiter
> their databases, or to allwo them access to Enterprise manager, from where
> they can administer their databases.
> thanks
> Martin[dot]Christopher[at]uk[dot]easynet[dot]net
>|||Yes, I think there is still a risk, but you could reduce this by using some
of the following:
You could use a stored procedure to execute their statements, and give the
user execute rights to this proc only.
By checking the type (sysobjects.type) of any tables they were trying to
access, you could limit their access to system objects.
"Martin c" <martin@.nospam.com> wrote in message
news:OFAWktQfDHA.556@.TK2MSFTNGP11.phx.gbl...
> I was considering a simple bit of ASP that allows them to riun SQL scripts
> (entered into a text box) on the server, and include some command
checking.
> The scripts would all be run under the contezt of the user in question.
> Would i be right in assuming though, that withough specific subroutines to
> avoid contact with any system databases, it would be possible for a
> malicious user to gleam enough information out of the server to launch an
> attackt hat has a fairly high probility of compramising the server ?
> M
>
> "Nick Hindle" <nick.hindle@.NOSPAMtesco.co.uk> wrote in message
> news:%23sS7GoQfDHA.460@.TK2MSFTNGP12.phx.gbl...
> > I think it's a bit risky to give folks access to Enterprise manager, and
> > it's not usually the done thing. By using a tool you develop you can
> control
> > exactly what the customer can do.
> >
> > "Martin c" <martin@.nospam.com> wrote in message
> > news:eINWglQfDHA.1888@.TK2MSFTNGP12.phx.gbl...
> > > (Please forgive me for cross posting on this one)
> > >
> > > I am attemptign to offer some kind of hosting of SQL databases as an
> > add-on
> > > to a Web Platform i have built. Unfortunately my SQL knowlwedge is a
> > little
> > > short of l33t.
> > >
> > > My question is this:
> > > Is it better to write a web front end to allow the customer to
> adminsiter
> > > their databases, or to allwo them access to Enterprise manager, from
> where
> > > they can administer their databases.
> > >
> > > thanks
> > > Martin[dot]Christopher[at]uk[dot]easynet[dot]net
> > >
> > >
> >
> >
>|||Thanks for your help here Nick. I'll go write soem code and see what i can
come up with.
M
"Nick Hindle" <nick.hindle@.NOSPAMtesco.co.uk> wrote in message
news:%23Fn9h3QfDHA.2400@.TK2MSFTNGP11.phx.gbl...
> Yes, I think there is still a risk, but you could reduce this by using
some
> of the following:
> You could use a stored procedure to execute their statements, and give the
> user execute rights to this proc only.
> By checking the type (sysobjects.type) of any tables they were trying to
> access, you could limit their access to system objects.
[SNIP]|||Hi Martin,
What kind of functions would you provide to the customer? If you want to
code yourself, it would require a lof of extra efforts if you want to
provide flexible management and functions.
If you fear that Enterprise Manager provides too many functions for
customer to easily destroy SQL Server databases, you can restrict their
permissions. And let them know that customers who do not need management
ability cannot install Enterprise Manager.
Bill Cheng
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
--
| From: "Martin c" <martin@.nospam.com>
| Subject: Hosting Environment - Advice please
| Date: Wed, 17 Sep 2003 11:49:29 +0100
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <eINWglQfDHA.1888@.TK2MSFTNGP12.phx.gbl>
| Newsgroups:
microsoft.public.sqlserver.security,microsoft.public.sqlserver.server,micros
oft.public.sqlserver.setup
| NNTP-Posting-Host: ninja.noc.uk.easynet.net 195.40.7.160
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.sqlserver.server:306886
microsoft.public.sqlserver.setup:57712
microsoft.public.sqlserver.security:15843
| X-Tomcat-NG: microsoft.public.sqlserver.server
|
| (Please forgive me for cross posting on this one)
|
| I am attemptign to offer some kind of hosting of SQL databases as an
add-on
| to a Web Platform i have built. Unfortunately my SQL knowlwedge is a
little
| short of l33t.
|
| My question is this:
| Is it better to write a web front end to allow the customer to adminsiter
| their databases, or to allwo them access to Enterprise manager, from where
| they can administer their databases.
|
| thanks
| Martin[dot]Christopher[at]uk[dot]easynet[dot]net
|
|
|