Showing posts with label record. Show all posts
Showing posts with label record. Show all posts

Monday, March 26, 2012

Mirror

is it possible to have a mirror of database in SQL SERVER 2000? thanks! so if i inserted a record in the first database, it will also be inserted on the other oneThere is nothing like a Mirror definition out in SQL Server. What we can do is to create two databases and have a Replication configured as a publisher and subscriber model. So when the publisher has a change the subscriber is notified of the changes and replicated.

Search for replication in SQL Server BOL for types of replication and the options available for the same.

Monday, March 19, 2012

Min/Maximum Grouping Query

I know this has been posted before, but I can't find the previous threads so please bear with me...

I want to grab the very 1st record of each product in a table like this

ID CLIENTID PRODID
1 a 1
2 b 1
3 c 1
4 a 2
5 b 2
6 c 2
7 a 3
8 b 3
9 c 3

so that I'd get a record set like:

ID CLIENTID PRODID
1 a 1
4 a 2
7 a 3

Thanks for the hellp guru'sSELECT t1.ID, t1.CLIENTID, t1.PRODID
FROM table t1
INNER JOIN (
SELECT MIN(ID) AS ID, PRODID
FROM table
ORDER BY PRODID) t2 ON t1.ID = t2.ID
AND t1.PRODID = t2.PRODID|||You did mean GROUP BY, not ORDER BY, right?

SELECT t1.ID, t1.CLIENTID, t1.PRODID
FROM table t1
INNER JOIN (
SELECT MIN(ID) AS ID, PRODID
FROM table
GROUP BY PRODID) t2 ON t1.ID = t2.ID
AND t1.PRODID = t2.PRODID|||Yep. Been sniped. (grin)|||Thanks guys, exactly what I was after. :)