Showing posts with label back. Show all posts
Showing posts with label back. Show all posts

Friday, March 23, 2012

On demand backups

Have a client that needs to do an "on demand" back up of a database. How
can this be done ?
The database in question is used by the accounting department and the
application uses the SA login to access the database.
Any insight would be greatful.
TIAThis is a multi-part message in MIME format.
--=_NextPart_000_0013_01C361A3.29261130
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Ok... after looking at the SQL server, it appears that the accounting =app is using a Login ID, that in turn is the dbo for the accounting =database, so I have given that ID the Backup DB permission on the =server. Now what can I do to place a short cut on the desktops so that =the database is backed up when click (thus on demand). Is there a =script file that I need to write or a command line to be entered ?
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:us9V7HcYDHA.656@.tk2msftngp13.phx.gbl...
An app with the sa password is like a 3-yr old with a .357 magnum. =Your accounting app should not have sysadmin rights. You can grant =BACKUP DATABASE to any login and that's all you would need for that.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"_M_" <here@.gone.com> wrote in message =news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
Have a client that needs to do an "on demand" back up of a database. =How
can this be done ?
The database in question is used by the accounting department and the
application uses the SA login to access the database.
Any insight would be greatful.
TIA
--=_NextPart_000_0013_01C361A3.29261130
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Ok... after looking at the SQL server, =it appears that the accounting app is using a Login ID, that in turn is =the dbo for the accounting database, so I have given that ID the Backup DB =permission on the server. Now what can I do to place a short cut on the =desktops so that the database is backed up when click (thus on demand). Is =there a script file that I need to write or a command line to be entered ?
"Tom Moreau" = wrote in message news:us9V7HcYDHA.656@.t=k2msftngp13.phx.gbl...
An app with the sa password is like =a 3-yr old with a .357 magnum. Your accounting app should not have sysadmin = rights. You can grant BACKUP DATABASE to any login and that's =all you would need for that.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"_M_" =wrote in message news:#KbMuEcYDHA.2464=@.TK2MSFTNGP09.phx.gbl...Have a client that needs to do an "on demand" back up of a database. Howcan this be done ?The database in question is used by =the accounting department and theapplication uses the SA login to =access the database.Any insight would be greatful.TIA

--=_NextPart_000_0013_01C361A3.29261130--|||This is a multi-part message in MIME format.
--=_NextPart_000_0338_01C361A5.7026B970
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
You can create a little .CMD file that has the following:
osql -SMyServer -E -Q"backup database MyDB to disk =3D 'C:\MyDB.bak'"
or
osql -SMyServer -UMyLogin -PMyPassword -Q"backup database MyDB to disk ==3D 'C:\MyDB.bak'"
Ideally, use Windows authentication as shown in the first example, so =that no one can see the password. Alternatively, you can write the =second one as:
osql -SMyServer -UMyLogin -Q"backup database MyDB to disk =3D ='C:\MyDB.bak'"
It will then prompt the user for the password.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"_M_" <here@.gone.com> wrote in message =news:O7KcoScYDHA.888@.TK2MSFTNGP10.phx.gbl...
Ok... after looking at the SQL server, it appears that the accounting =app is using a Login ID, that in turn is the dbo for the accounting =database, so I have given that ID the Backup DB permission on the =server. Now what can I do to place a short cut on the desktops so that =the database is backed up when click (thus on demand). Is there a =script file that I need to write or a command line to be entered ?
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:us9V7HcYDHA.656@.tk2msftngp13.phx.gbl...
An app with the sa password is like a 3-yr old with a .357 magnum. =Your accounting app should not have sysadmin rights. You can grant =BACKUP DATABASE to any login and that's all you would need for that.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"_M_" <here@.gone.com> wrote in message =news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
Have a client that needs to do an "on demand" back up of a database. =How
can this be done ?
The database in question is used by the accounting department and the
application uses the SA login to access the database.
Any insight would be greatful.
TIA
--=_NextPart_000_0338_01C361A5.7026B970
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

You can create a little .CMD file that =has the following:
osql -SMyServer -E -Q"backup =database MyDB to disk =3D 'C:\MyDB.bak'"
or
osql -SMyServer -UMyLogin -PMyPassword -Q"backup database MyDB to disk =3D ='C:\MyDB.bak'"
Ideally, use Windows authentication as shown in the first example, =so that no one can see the password. Alternatively, you can write the =second one as:
osql -SMyServer =-UMyLogin -Q"backup database MyDB to disk =3D 'C:\MyDB.bak'"
It will then prompt the user for the =password.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"_M_" =wrote in message news:O7KcoScYDHA.888@.T=K2MSFTNGP10.phx.gbl...
Ok... after looking at the SQL server, =it appears that the accounting app is using a Login ID, that in turn is =the dbo for the accounting database, so I have given that ID the Backup DB =permission on the server. Now what can I do to place a short cut on the =desktops so that the database is backed up when click (thus on demand). Is =there a script file that I need to write or a command line to be entered ?
"Tom Moreau" = wrote in message news:us9V7HcYDHA.656@.t=k2msftngp13.phx.gbl...
An app with the sa password is like =a 3-yr old with a .357 magnum. Your accounting app should not have sysadmin = rights. You can grant BACKUP DATABASE to any login and that's =all you would need for that.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"_M_" =wrote in message news:#KbMuEcYDHA.2464=@.TK2MSFTNGP09.phx.gbl...Have a client that needs to do an "on demand" back up of a database. Howcan this be done ?The database in question is used by =the accounting department and theapplication uses the SA login to =access the database.Any insight would be greatful.TIA

--=_NextPart_000_0338_01C361A5.7026B970--|||Dbo does not have to have backup database permission. A dbo can do anything
to the database that he/she owns..
Here is something short I did
1. create this proc ( you need to adjust the db name)
create proc dbo.bu as
declare @.fname varchar(128)
select @.fname = 'c:\' +
db_name() + '_DB_' + convert(varchar(100), getdate(),112)
+ datename(hh,getdate()) + datename(mi,getdate())
--select @.fname
backup database northwind to disk = @.fname
create a dos batch job like this
OSQL -Ulogin -Ppassword -Q"exec dbname.dbo.bu"
when the job is run the backup occurs...
Then put a shortcut to the job on their desktop
I would create a new login for the database which has ONLY backup
permissions, since the login and password are easily found...
Wayne Snyder, MCDBA, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and its
community of SQL Server professionals.
www.sqlpass.org
"_M_" <here@.gone.com> wrote in message
news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
> Have a client that needs to do an "on demand" back up of a database. How
> can this be done ?
> The database in question is used by the accounting department and the
> application uses the SA login to access the database.
> Any insight would be greatful.
> TIA
>|||I like both yours and Tom's responses... Can yours be modified to use
Windows Authentication or can Tom's be modified to save each backup in the
time-date file name like yours ?
I'm sort of new to this SQL server stuff but I have had a semester of DB in
college...
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message
news:OVu5IfcYDHA.2524@.TK2MSFTNGP09.phx.gbl...
> Dbo does not have to have backup database permission. A dbo can do
anything
> to the database that he/she owns..
> Here is something short I did
> 1. create this proc ( you need to adjust the db name)
> create proc dbo.bu as
> declare @.fname varchar(128)
> select @.fname = 'c:\' +
> db_name() + '_DB_' + convert(varchar(100), getdate(),112)
> + datename(hh,getdate()) + datename(mi,getdate())
> --select @.fname
> backup database northwind to disk = @.fname
> create a dos batch job like this
> OSQL -Ulogin -Ppassword -Q"exec dbname.dbo.bu"
> when the job is run the backup occurs...
> Then put a shortcut to the job on their desktop
> I would create a new login for the database which has ONLY backup
> permissions, since the login and password are easily found...
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Computer Education Services Corporation (CESC), Charlotte, NC
> www.computeredservices.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and its
> community of SQL Server professionals.
> www.sqlpass.org
>
> "_M_" <here@.gone.com> wrote in message
> news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
> > Have a client that needs to do an "on demand" back up of a database.
How
> > can this be done ?
> >
> > The database in question is used by the accounting department and the
> > application uses the SA login to access the database.
> >
> > Any insight would be greatful.
> >
> > TIA
> >
> >
>|||This is a multi-part message in MIME format.
--=_NextPart_000_03C3_01C361AA.859BF130
Content-Type: text/plain;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Tom's can be modified. ;-) Just have it execute the proc instead of =the raw BACKUP:
osql -SMyServer -E -Q"exec MyBackupProc"
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"_M_" <here@.gone.com> wrote in message =news:uofpKqcYDHA.2448@.TK2MSFTNGP09.phx.gbl...
I like both yours and Tom's responses... Can yours be modified to use
Windows Authentication or can Tom's be modified to save each backup in =the
time-date file name like yours ?
I'm sort of new to this SQL server stuff but I have had a semester of DB =in
college...
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message
news:OVu5IfcYDHA.2524@.TK2MSFTNGP09.phx.gbl...
> Dbo does not have to have backup database permission. A dbo can do
anything
> to the database that he/she owns..
> Here is something short I did
> 1. create this proc ( you need to adjust the db name)
> create proc dbo.bu as
> declare @.fname varchar(128)
> select @.fname =3D 'c:\' +
> db_name() + '_DB_' + convert(varchar(100), getdate(),112)
> + datename(hh,getdate()) + datename(mi,getdate())
> --select @.fname
> backup database northwind to disk =3D @.fname
> create a dos batch job like this
> OSQL -Ulogin -Ppassword -Q"exec dbname.dbo.bu"
> when the job is run the backup occurs...
> Then put a shortcut to the job on their desktop
> I would create a new login for the database which has ONLY backup
> permissions, since the login and password are easily found...
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Computer Education Services Corporation (CESC), Charlotte, NC
> www.computeredservices.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and its
> community of SQL Server professionals.
> www.sqlpass.org
>
> "_M_" <here@.gone.com> wrote in message
> news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
> > Have a client that needs to do an "on demand" back up of a database.
How
> > can this be done ?
> >
> > The database in question is used by the accounting department and =the
> > application uses the SA login to access the database.
> >
> > Any insight would be greatful.
> >
> > TIA
> >
> >
>
--=_NextPart_000_03C3_01C361AA.859BF130
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Tom's can be modified. ;-) =Just have it execute the proc instead of the raw BACKUP:
osql -SMyServer -E -Q"exec MyBackupProc"
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"_M_" =wrote in message news:uofpKqcYDHA.2448=@.TK2MSFTNGP09.phx.gbl...I like both yours and Tom's responses... Can yours be modified to useWindows Authentication or can Tom's be modified to save each =backup in thetime-date file name like yours ?I'm sort of new to this =SQL server stuff but I have had a semester of DB =incollege..."Wayne Snyder" wrote in messagenews:OVu5IfcYDHA.2524=@.TK2MSFTNGP09.phx.gbl...> Dbo does not have to have backup database permission. A dbo can doanything> to the database that he/she =owns..>> Here is something short I did> 1. create this proc ( you need to =adjust the db name)> create proc dbo.bu as> declare @.fname =varchar(128)> select @.fname =3D 'c:\' +> db_name() + '_DB_' + =convert(varchar(100), getdate(),112)> + datename(hh,getdate()) + datename(mi,getdate())> --select @.fname> backup database =northwind to disk =3D @.fname>> create a dos batch job like =this> OSQL -Ulogin -Ppassword -Q"exec dbname.dbo.bu">> when the job =is run the backup occurs...>> Then put a shortcut to the job on =their desktop>> I would create a new login for the database =which has ONLY backup> permissions, since the login and password are easily =found...>>> --> Wayne Snyder, MCDBA, SQL =Server MVP> Computer Education Services Corporation (CESC), Charlotte, NC>http://www.computeredservices.com">www.computeredservices.com=> (Please respond only to the newsgroups.)>> I support the Professional Association of SQL Server (PASS) and its> community =of SQL Server professionals.>>&g=">http://www.sqlpass.org">www.sqlpass.org>>&g=t; "_M_" wrote in message> news:#KbMuEcYDHA.2464=@.TK2MSFTNGP09.phx.gbl...> > Have a client that needs to do an "on demand" back up of a database.How> > can this be done ?> >> => The database in question is used by the accounting department and =the> > application uses the SA login to access the database.> =>> > Any insight would be greatful.> >> > TIA> >> >>>

--=_NextPart_000_03C3_01C361AA.859BF130--|||Tried to create the procedure as listed by Wayne... I get an error message
(Invalid syntax at or around backup"
I did do a cut and paste as well as completely re-typing it myself. The
server is SQL 2000 if that matters...
"Wayne Snyder" <wsnyder@.computeredservices.com> wrote in message
news:OVu5IfcYDHA.2524@.TK2MSFTNGP09.phx.gbl...
> Dbo does not have to have backup database permission. A dbo can do
anything
> to the database that he/she owns..
> Here is something short I did
> 1. create this proc ( you need to adjust the db name)
> create proc dbo.bu as
> declare @.fname varchar(128)
> select @.fname = 'c:\' +
> db_name() + '_DB_' + convert(varchar(100), getdate(),112)
> + datename(hh,getdate()) + datename(mi,getdate())
> --select @.fname
> backup database northwind to disk = @.fname
> create a dos batch job like this
> OSQL -Ulogin -Ppassword -Q"exec dbname.dbo.bu"
> when the job is run the backup occurs...
> Then put a shortcut to the job on their desktop
> I would create a new login for the database which has ONLY backup
> permissions, since the login and password are easily found...
>
> --
> Wayne Snyder, MCDBA, SQL Server MVP
> Computer Education Services Corporation (CESC), Charlotte, NC
> www.computeredservices.com
> (Please respond only to the newsgroups.)
> I support the Professional Association of SQL Server (PASS) and its
> community of SQL Server professionals.
> www.sqlpass.org
>
> "_M_" <here@.gone.com> wrote in message
> news:#KbMuEcYDHA.2464@.TK2MSFTNGP09.phx.gbl...
> > Have a client that needs to do an "on demand" back up of a database.
How
> > can this be done ?
> >
> > The database in question is used by the accounting department and the
> > application uses the SA login to access the database.
> >
> > Any insight would be greatful.
> >
> > TIA
> >
> >
>sql

Wednesday, March 21, 2012

Oledb/Data Access Problems

Hi all,

I am going a bit crazy here. To give you my back ground I have done quite some work on SQL server 2000, VFP, VB6 and done quite a few web pages using frontpage. Now I am venturing into aspnet and have what seems to be some data access problems.

I got a win2k professional web server and its running/has been running my frontpage web pages quite nicely either accessing them as //localhost/myweb or www.mydomain/myweb.

Now I made some web pages in Visual Web Developer express to get my "feet wet" So I installed SQL 5.0 express on that machine, .net2.0 and VWD express and vfpoledb. I got 2 web sites designed. One to explore the login feature. Made a default web page and 2 more pages on which I display some SQL grid views from a local db I set up. Site works fine both in the test environment and also on the webserver accessed over the web. Then I added a login page with a login control and configured the site for "web Access", set up 3 test users and pw, no roles and configured the access rules to annonymous denie and all the users allow. Works great out of the VWD environment (view in browser) but when run from the web no PW is ever correct.

2nd problem on 2nd site.

Access to a VFP9.0 table via OLEDB works great again out of the design environment (View in browser) but then run from the wwroot./vfptest directory it comes up with an OLEDB error indicating it cannot find the file

any ideas?

Could you provide more details, exact error message, connection string, etc.?

Thanks

|||

I found the solution to all the problems above

Go to IIS and go to the ASPNET configuration and application tab and set the "Local impersonation" check mark and put in a user that can access the SQL or other files

Tuesday, March 20, 2012

OLEDB driver omits SP return value

Hi,

I have a problem with some ATL7/OLEDB code. I'm trying to execute stored procedures from my application. I do get a result set back, but I never get a correct return value back. I've been going through MSDN articles as well as other articles on the web, and I just cannot see what I'm doing wrong!

I have this piece of ATL code:
<pre>
// code generated on den 6 juni 2002, 10:56

[
db_command(L"{ ? = CALL dbo.MyProc(?) }")
]
class CMyProc
{
public:
[ db_column(1, status=m_dwIdStatus, length=m_dwIdLength) ] LONG m_Id;
/* and so on - 7 columns total */

[ db_param(1, DBPARAMIO_OUTPUT) ] LONG m_RETURN_VALUE;
[ db_param(2, DBPARAMIO_INPUT) ] LONG m_id;

void GetRowsetProperties(CDBPropSet* pPropSet)
{
pPropSet->AddProperty(DBPROP_CANFETCHBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
pPropSet->AddProperty(DBPROP_CANSCROLLBACKWARDS, true, DBPROPOPTIONS_OPTIONAL);
}
};

</pre>

When I use this code I do:
<pre>
CSession dbsession;
CDataSource dbsource;
CDBPropSet dbinit(DBPROPSET_DBINIT);
/* fill dbinit with connection parameters */
/* HRESULTs not checked for brevity*/
dbsource.Open(_T("SQLOLEDB.1"), &dbinit);
dbsession.Open(dbsource);

CMyProc proc;
proc.m_id = 1;
proc.Open(dbsession);

TRACE("Return value is %d\n", proc.m_RETURN_VALUE);

/* Take care of result set - which exists and is valid! */
</pre>

The return value is <tt>-858993460</tt> which is <tt>0xcccccccc</tt>. In Visual C++ this value is used as an "uninitialized" stack value during debug. It seems as if ATL never bothers to update my return value parameters! I even made a little experiment with an extra output parameter - same thing there.

I'm using Visual C++ .NET and the SQL 2000 OLEDB provider (SP2). I've also tried this without attributed programming in both Visual C++ .NET and Visual C++ 6.

Does anybody have a clue what is going on??Is the stored procedure using set nocount on ? If not, put it in the stored procedure.

Good luck.|||Thanks for replying!

I tried with and without nocount and had no success.

I tried something else the other day though; I generated a non-attributed CCommand-class using CMultipleResults as template parameter. Then I could get all out parameters by calling GetNextResult() on the command object.

So my question is now; how do I make the attribute-injector generate a CCommand class for me using CMultipleResults?