Showing posts with label based. Show all posts
Showing posts with label based. Show all posts

Thursday, March 29, 2012

dba activities

can any one tell me what are the sql server dba activities?
i'm a junnior dba in hyderabad, my organization is product based company.

i need the general activities, so that i can become master in atleast some aspects.

generally what is the expectations of big organizations from DBA's? especially i'm plannning for H1.Hi,

Ativities of DBA are :

server management(making optimized)
security
recovery and back up

Regards,
Sharmila

Quote:

Originally Posted by vinod

can any one tell me what are the sql server dba activities?
i'm a junnior dba in hyderabad, my organization is product based company.

i need the general activities, so that i can become master in atleast some aspects.

generally what is the expectations of big organizations from DBA's? especially i'm plannning for H1.

|||can any one tell me what are the informix server dba activities?
i'm dba in a finance company

i need the general activities, so that i can become master in atleast some aspects.|||For any database the DBA activities are almost similar.

you are supposed to work on

1. Server maintananace
2. Backup & Recovery.
3. Optimization / Tuning.
etc along with your daily activities ,which varies from organisation to otrganisation.

those might include
1. taking daily logs
2. user management
..........
and a few others.

Thursday, March 22, 2012

DB Stuck on (Loading) After Restore

We are using MS SQL Server 2000.
I am not a proficient SQL user.
I have created many databases based on a set of instructions from a former
consultant. This involves doing a restore from a SQL backup (to disk) of an
existing "shell" database and "restore as" a new database name. When
selecting options for the restore, I select "leave database operational."
Yesterday when I tried to do this, the progress bar went all the way across,
but then an error popped up at the end that said:
The log in this backup set begins at LSN 30200000 blah blah blah which is
too late to apply to the database. An earlier log backup that includes
30020202020 can be restored. RESTORE LOG is terminating abnormally.
In enterprise manager, my new database appears, but it is grayed out with
the word (loading) next to it.
I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but I
have no idea where or how to do this, or even if this is the right thing to
do.
Would someone point me in the right direction?
Thank youmike wrote:
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but
I
> have no idea where or how to do this, or even if this is the right thing t
o
> do.
> Would someone point me in the right direction?
> Thank you
>
That RESTORE command would be run in Query Analyzer. The biggest favor
that you can do yourself, if you're going to be working with SQL, is to
wean yourself from the point-and-click mentality and learn how to use
Query Analyzer to manipulate your databases. Everything you do in
Enterprise Manager is converted into T-SQL commands that are then sent
to the database. You can issue the same commands yourself via Query
Analyzer, and you'll have a firm understanding of what's going on "under
the hood".|||mike wrote:
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but
I
> have no idea where or how to do this, or even if this is the right thing t
o
> do.
> Would someone point me in the right direction?
> Thank you
>
That RESTORE command would be run in Query Analyzer. The biggest favor
that you can do yourself, if you're going to be working with SQL, is to
wean yourself from the point-and-click mentality and learn how to use
Query Analyzer to manipulate your databases. Everything you do in
Enterprise Manager is converted into T-SQL commands that are then sent
to the database. You can issue the same commands yourself via Query
Analyzer, and you'll have a firm understanding of what's going on "under
the hood".|||mike
drop database test
go
create database test
GO
create table test..test(id int identity)
insert test..test default values
backup database test to disk = 'd:\db.bak' WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak'WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak' WITH NOINIT
GO
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, recovery
GO
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, norecovery
GO
"mike" <mike@.commmcasssttt.com> wrote in message
news:12a5vvi5kq0l1a6@.corp.supernews.com...
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have created many databases based on a set of instructions from a former
> consultant. This involves doing a restore from a SQL backup (to disk) of
> an existing "shell" database and "restore as" a new database name. When
> selecting options for the restore, I select "leave database operational."
> Yesterday when I tried to do this, the progress bar went all the way
> across, but then an error popped up at the end that said:
> The log in this backup set begins at LSN 30200000 blah blah blah which is
> too late to apply to the database. An earlier log backup that includes
> 30020202020 can be restored. RESTORE LOG is terminating abnormally.
> In enterprise manager, my new database appears, but it is grayed out with
> the word (loading) next to it.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but
> I have no idea where or how to do this, or even if this is the right thing
> to do.
> Would someone point me in the right direction?
> Thank you
>|||mike
drop database test
go
create database test
GO
create table test..test(id int identity)
insert test..test default values
backup database test to disk = 'd:\db.bak' WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak'WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak' WITH NOINIT
GO
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, recovery
GO
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, norecovery
GO
"mike" <mike@.commmcasssttt.com> wrote in message
news:12a5vvi5kq0l1a6@.corp.supernews.com...
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have created many databases based on a set of instructions from a former
> consultant. This involves doing a restore from a SQL backup (to disk) of
> an existing "shell" database and "restore as" a new database name. When
> selecting options for the restore, I select "leave database operational."
> Yesterday when I tried to do this, the progress bar went all the way
> across, but then an error popped up at the end that said:
> The log in this backup set begins at LSN 30200000 blah blah blah which is
> too late to apply to the database. An earlier log backup that includes
> 30020202020 can be restored. RESTORE LOG is terminating abnormally.
> In enterprise manager, my new database appears, but it is grayed out with
> the word (loading) next to it.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but
> I have no idea where or how to do this, or even if this is the right thing
> to do.
> Would someone point me in the right direction?
> Thank you
>|||Thank you both|||Thank you both

DB Stuck on (Loading) After Restore

We are using MS SQL Server 2000.
I am not a proficient SQL user.
I have created many databases based on a set of instructions from a former
consultant. This involves doing a restore from a SQL backup (to disk) of an
existing "shell" database and "restore as" a new database name. When
selecting options for the restore, I select "leave database operational."
Yesterday when I tried to do this, the progress bar went all the way across,
but then an error popped up at the end that said:
The log in this backup set begins at LSN 30200000 blah blah blah which is
too late to apply to the database. An earlier log backup that includes
30020202020 can be restored. RESTORE LOG is terminating abnormally.
In enterprise manager, my new database appears, but it is grayed out with
the word (loading) next to it.
I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but I
have no idea where or how to do this, or even if this is the right thing to
do.
Would someone point me in the right direction?
Thank youmike wrote:
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but I
> have no idea where or how to do this, or even if this is the right thing to
> do.
> Would someone point me in the right direction?
> Thank you
>
That RESTORE command would be run in Query Analyzer. The biggest favor
that you can do yourself, if you're going to be working with SQL, is to
wean yourself from the point-and-click mentality and learn how to use
Query Analyzer to manipulate your databases. Everything you do in
Enterprise Manager is converted into T-SQL commands that are then sent
to the database. You can issue the same commands yourself via Query
Analyzer, and you'll have a firm understanding of what's going on "under
the hood".|||mike
drop database test
go
create database test
GO
create table test..test(id int identity)
insert test..test default values
backup database test to disk = 'd:\db.bak' WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak'WITH INIT
insert test..test default values
backup log test to disk = 'd:\log.bak' WITH NOINIT
GO
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, recovery
GO
RESTORE DATABASE test FROM disk = 'd:\db.bak' WITH FILE = 1, norecovery
RESTORE LOG test FROM disk = 'd:\log.bak' WITH FILE = 2, norecovery
GO
"mike" <mike@.commmcasssttt.com> wrote in message
news:12a5vvi5kq0l1a6@.corp.supernews.com...
> We are using MS SQL Server 2000.
> I am not a proficient SQL user.
> I have created many databases based on a set of instructions from a former
> consultant. This involves doing a restore from a SQL backup (to disk) of
> an existing "shell" database and "restore as" a new database name. When
> selecting options for the restore, I select "leave database operational."
> Yesterday when I tried to do this, the progress bar went all the way
> across, but then an error popped up at the end that said:
> The log in this backup set begins at LSN 30200000 blah blah blah which is
> too late to apply to the database. An earlier log backup that includes
> 30020202020 can be restored. RESTORE LOG is terminating abnormally.
> In enterprise manager, my new database appears, but it is grayed out with
> the word (loading) next to it.
> I have googled and some suggestions say to do a RESTORE WITH RECOVERY, but
> I have no idea where or how to do this, or even if this is the right thing
> to do.
> Would someone point me in the right direction?
> Thank you
>|||Thank you both

Thursday, March 8, 2012

DB Performance

I ave the following Code in my Stored procedure.

Declare Cursor for table A
WHILE @.@.FETCH_STATUS = 0
Get values from other function based on some business logic.
INSERT Into another table B
(or)
UPDATE to another table B
END

I have to insert/update values to table B, one by one row. So, it is taking more time.
Is there any way to collect the values into a temporary storage and Insert/update or Move the values to table B.Why do you use a cursor ? It's not performant for this type of query...|||While you can certainly do that, in some instances (such as those which don't involve the tables possibly being updated in real-time), you might be able to accomplish a similar effect by wrapping the request in a transaction having an appropriate isolation-level. What you're trying to do here is to delay disk-writes and make more efficient use of in-memory buffers.

You can also sometimes achieve good results by sorting the records that are being updated, so that they are presented to the system (say) in primary-key order. Once again, we're trying to improve the chances that the next record we're going to be updating is nearby to the last one, and thus "still available in our in-memory buffers."

Sorting is an "unexpectedly fast and efficient" thing for a computer to do. "Random-access anything" is inherently slower due to the mechanical delays of moving the read/write head about.
"I/O!... I/O!... it's off to disk we go!" ;)
"Seek, and ye shall wait." :D|||Originally posted by fadace
Why do you use a cursor ? It's not performant for this type of query...

How can avoid Cursor. My Exact query is like this..
DECLARE cur_populate_CachePrograms CURSOR FOR
SELECT e.EmployeeCode,
FROM tbl_Employee e
WHERE e.IsActive = 1
ORDER BY e.EmployeeCode

OPEN cur_populate_CachePrograms

FETCH NEXT FROM cur_populate_CachePrograms INTO @.EmployeeCode

WHILE @.@.FETCH_STATUS = 0
BEGIN
exec usp_PopulateCacheTable_VarPay3 @.EmployeeCode, @.IsVarPay3NeedComments OUTPUT

IF EXISTS(select EmployeeCode from tbl_Program where EmployeeCode = @.EmployeeCode)
BEGIN
UPDATE tbl_CacheEmployeeToProgram
SET IsVarPay3NeedComments = @.IsVarPay3NeedComments,
WHERE @.EmployeeCode = EmployeeCode
END
ELSE
BEGIN
INSERT INTO tbl_Program
(EmployeeCode, IsVarPay3NeedComments) VALUES (@.EmployeeCode,@.IsVarPay3NeedComments)
END

FETCH NEXT FROM cur_populate_CachePrograms INTO @.EmployeeCode

END
CLOSE cur_populate_CachePrograms
DEALLOCATE cur_populate_CachePrograms|||Depending on what is going on in usp_PopulateCacheTable_VarPay3, you might be able to change it to a function which returns @.IsVarPay3NeedComments. You can then use the function in-line in you SQL statement.

Something like, and this is sketchy guess-work with what info I have...

UPDATE tbl_CacheEmployeeToProgram
SET IsVarPay3NeedComments = uFN_PopulateCacheTable_VarPay3(tbl_Employee.Employ eeCode)
FROM tbl_CacheEmployeeToProgram
INNER JOIN tbl_Employee

SELECT e.EmployeeCode,
FROM tbl_Employee e
WHERE e.IsActive = 1
ORDER BY e.EmployeeCode|||Sorry, hit the Enter Key accidently. Let's try that again...

Depending on what is going on in usp_PopulateCacheTable_VarPay3, you might be able to change it to a function which returns @.IsVarPay3NeedComments. You can then use the function in-line in you SQL statement.

Something like, and this is sketchy guess-work with what info I have...

UPDATE tbl_CacheEmployeeToProgram
SET IsVarPay3NeedComments = uFN_PopulateCacheTable_VarPay3(tbl_Employee.Employ eeCode)
FROM tbl_CacheEmployeeToProgram
INNER JOIN tbl_Employee
ON tbl_CacheEmployeeToProgram.EmployeeCode = tbl_Employee.EmployeeCode
INNER JOIN tbl_Program
ON tbl_Employee.EmployeeCode = tbl_Program.EmployeeCode|||Oh, and add

WHERE tbl_Employee.IsActive=1|||usp_PopulateCacheTable_VarPay3 is going to return more than one value...
So, I can't use function|||You can have it return a result set (TABLE)|||But if function uFN_PopulateCacheTable_VarPay3 returns TABLE variable which contains more than one variable, how do I set to multiple columns.

UPDATE tbl_program
SET IsVarPay3NeedComments = uFN_PopulateCacheTable_VarPay3(tbl_Employee.Employ eeCode)|||Use it like a table in your select statement:

SELECT IsVarPay3NeedComments FROM dbo.uFN_PopulateCacheTable_VarPay3(tbl_Employee.Em ployeeCode)

So your statement would be something like:

UPDATE tbl_CacheEmployeeToProgram
SET IsVarPay3NeedComments = mytable.IsVarPay3NeedComments
FROM uFN_PopulateCacheTable_VarPay3(tbl_Employee.Employ eeCode) mytable
INNER JOIN tbl_CacheEmployeeToProgram
ON mytable.EmployeeCode = tbl_CacheEmployeeToProgram.EmployeeCode
INNER JOIN tbl_Employee
ON tbl_CacheEmployeeToProgram.EmployeeCode = tbl_Employee.EmployeeCode
INNER JOIN tbl_Program
ON tbl_Employee.EmployeeCode = tbl_Program.EmployeeCode

In order for that to work (in my statement anyway), you should return a table that is something like:
RETURNS TABLE (EmployeeCode INT, IsVarPay3NeedComments VARCHAR(100))|||and the WHERE statement again!!! DOH!