|
Execute this command after setting the connection and before restoring the DB
ALTER DATABASE LIDER SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Of course, the ramifications being that any user connected to the DB will lost connection and any open transactions will be rolled back. It's pertinent for you to check if there are any existing users first, any running transactions first and then do the recovery.
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
how can i restore database to exists database.?
|
|
|
|
|
tr_thorn wrote: how can i restore database to exists database.?
Using these[^] command
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
Can anybody guide me as to how do we
call a cursor having rows more than 10000?
Manish Ganguly
|
|
|
|
|
I am afraid that you might be running under performance issues when you are working with cursors on a table with more than 10000 rows.
Best bet will be to try populating your records onto a temporary table or table variable.
Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon
|
|
|
|
|
HI CS,
I GOT WHAT U SAID.
THIS IS MY SCENARIO:
1. PICK UP DATA FROM A TEMPORARY TABLE ROW BY ROW......VALIDATE WHETHER THEY FOLLOW BUSINESS LOGIC OR NOT.
2. IF THE DATA IS ERRONEOUS UPDATE A FLAG IN THE SAME TABLE TO F, ELSE UPDATE IT TO P.
Manish Ganguly
|
|
|
|
|
Please don't shout. First of all, can you perform your business logic in SQL? If you can, you can possibly do this without having to use a cursor at all. It's always best to use SET based updates wherever possible, so you could use something like:
INSERT INTO myTable (myCondition1, myValue1, myOtherValue, myValue) VALUES ('...', 1, 2, 'F')
UPDATE myTable mt
SET myValue = 'P'
WHERE myCondition1 = 'Hello' AND myValue1 > 30 AND myOtherValue >
(Select SUM(oValue) FROM otherTable ot WHERE mt.PrimaryKey = ot.ForeignKey) As you can see, the initial insert creates the record and sets it's validity to false. The update is then used later on in your processing to update the records to P that have passed the test.
|
|
|
|
|
Hi Manish
What database product are you using?
Note that some databases (particularly SQL-Server), cursors are considerably slower set-based operations. Cursors would only normally be considered for reeeeeeally complex business rules).
Under SQL-Server, if you really have to use a cursor, it would be something along the lines of:
declare c1 cursor for
select field1, field2, etc
from YourTable
for update of MyFlag
open c1
fetch c1 into @Field1, @Field2, @Etc
while (@@FETCH_STATUS <> 0) begin
set @MyFlag = 'P'
--Do business logic checks here - if error then set @MyFlag to 'F'.
update YourTable set MyFlag = @MyFlag
where current of c1
fetch c1 into @Field1, @Field2, @Etc
end
close c1
deallocate c1 The code is similar in other types of databases too.
Regards
Andy
|
|
|
|
|
You were actually given some valuable help by some one. So why are you angry at the person who has helped you by expressing yourself in 'All Capitals'.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
I am extremely sorry if u have mistook my All Caps as being angry.
I was coding the Stored Proc at that time......and as per company standards I had to keep it in All Caps. I am sorry , I forgot to switch it off while typing my problem.
Anyways Guys, Cheerz.
We have found a roundabout way of handling it.
While checking the "select" query was imposing a big chunk, so we have decided to design a tertiary table and use it directly to fetch the records from them. This improved my time around 45%.
What intially took us 2:30 hrs to implement 10 lakh records, is now taking us 1:20 hrs.
Tx guys for all the help u have provided.
Manish Ganguly.
|
|
|
|
|
Hello,
I have the following procedure
CREATE PROCEDURE tryproc AS
declare @first int;
select sum(t) as first from demand where product='LPG' AND LOCATION = 'Mumbai';
create table abc (demandsum int);
insert into abc (demandsum) values (@first);
In the above procedure the value inserted in te table is NULL. I want the sum got from the table to be inserted in the table abc.
What must be the problem?
Prithaa
|
|
|
|
|
prithaa wrote: What must be the problem?
Problem is you are not assigning the variable value. See this and rewrite it
CREATE PROCEDURE tryproc
AS
DECLARE @first INT
SET @first = ( SELECT SUM(t) AS first
FROM demand
WHERE product = 'LPG'
AND LOCATION = 'Mumbai' )
CREATE TABLE abc (demandsum INT)
INSERT INTO abc (demandsum) VALUES (@first) Hope it helps
|
|
|
|
|
Hi,
you can use this query ...
however you can reduce the no. of DML stm..
SELECT dem.first INTO abc FROM
(SELECT SUM(t) AS first FROM demand WHERE product = 'LPG' AND LOCATION = 'Mumbai' ) dem
|
|
|
|
|
I wanted a code which would connect with the MS Access database.
|
|
|
|
|
what is your front-end ?
|
|
|
|
|
my front end will be asp.net.
|
|
|
|
|
|
Hello Experts,
Suppose I have three fields in table named ID,Order Date and Order NO.
I have to fetch the max order no along with their Id and date. actually I have more than 1000 records on a particular date. So I have to fetch max order no and max order date.....
Please help
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
try like:
select max(OrderNo), max(orderDate) from <tablename>
|
|
|
|
|
That is not working properly. I want to know max order date first and
after that what is the max order no on that particular date.
Please help.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
Hi,
Use this query...
select id ,ord_num, ord_Date
from <table_name>
where ord_num = (select max(ord_num) from <table_name> where ord_Date =(select max(ord_Date) from <table_name>))
|
|
|
|
|
Thank you for reply.
Regards
Pankaj Joshi
If you want to shape your dreams into reality, please wake-up...
|
|
|
|
|
I know this question doesn't really fit here, and should probably be asked of some db admin types on another site, but I don't know of any such sites/people, so I thought I'd give you guys a shot...
I have an ASP.Net web service backed by SQL Server 2005 Standard happily running on a server hosted in or near Canary Warf. It's been up for 6 Months, with no down time except for scheduled maintenance. However, I've finally gotten funding to do what I wanted to do in the first place, and replicate the whole she-bang in a completely different part of the country, just so that when the inevitable happens (such as a builder cutting through the internet pipe at the host) the service can continue running with the minimum of fuss.
Whilst I can quite easily manage keeping the ASP.Net side of things in sync (unless anyone knows how to have IIS do this for me?), keeping the two databases synchronized might be more of a challenge.
Now I understand SQL Server has all manner of features that can do this kind of thing, but I'm googling around without really knowing what to google for. Database Mirroring keeps coming up, but I'm not sure if this is what I want - is it? Or is replication what I should be looking for (having read about the publisher/subscriber model, I'm unclear how we'd be able to get stuff back from the backup database on to the primary, once the primary has recovered)?
Cheers,
Martin.
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Yup - mirroring is what you want. This[^] article is a good start.
|
|
|
|
|
Cool - cheers!
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|