Showing posts with label methods. Show all posts
Showing posts with label methods. Show all posts

Wednesday, March 21, 2012

How to detect replication doesnt work and get noticed?

I want to get notice by netsend, email or any other methods
when replication doesn't work or malfunction.
Does anyone know how to do this or any other solution you use for this kind of issue?
Thank you..Every agent that runs your replication (snapshot, logreader, distributot, and queuereader) have associated SQLAgent jobs. All you have to do is modify those jobs by going to Notification tab of the job properties and selecting notification method you'd like to get. You should have an appropriate operator set up before, or you can do it right there by selecting New Operator.|||Thank you for reply..

The main problem I have is how to find out if the replication doesn't work..
I can notice with agent history or icon.

Sometimes the icon become X marked, some times agent keep trying to connect and generate error with forever loop, sometimes gives I/O error while working..

How to find out these and what's best way to find out if replication doesn't work properly?|||Have you looked at what I posted about?|||Yes I did..
I knew that part..
Could you give me more detail with example with specific error cases?
Then, I understand more clearly.|||see attachment|||Thank you for the image..
I think I got it at this level..

I just wonder is there a way to run a custom application when job fails rather than sending Net-send..

Since I have to check hundreds of systems replicated, if I use net-send I will get too much of it and hard to maintain.
If I can run my custome application reporting problem organized, it will be easy to maintain.|||In that case you should create a batch file and call it from task window .

In SQL Scheduler when you click on the task and click advanced it says

" On failure action: and then there is a drop down . All you have to do is add another task to the existing job and call it here

It will say

"On failure Action : Goto Step #2" In that step #2 you can all the windows batch file .. (which can contain anything like ISQL, another program ...)|||Thank you!
I got it!|||Another way of doing it would be to create a custom alert and a scheduled task. When conditions for the alert are met you can invoke that scheduled task that may contain ... see previous post.

Sunday, February 19, 2012

How to define composite key?

Hello, everyone:
I need to define composite PK and FK for a ERD. Could someone offer the methods that work with,
1. T-SQL
2. ERD
Thanks a lot.
ZYTThe question is more complex than it seems, so the answer will be a bit "long winded".

1) You define PK and FK using a contraint within Transact SQL. The constraint types are PRIMARY KEY and FOREIGN KEY. For example:
CREATE TABLE composite (
compositeId INT NOT NULL
CONSTRAINT XPKcomposite
PRIMARY KEY (compositeId)
, name VARCHAR(50) NOT NULL
)

CREATE TABLE component (
componentId INT NOT NULL
CONSTRAINT XPKcomponent
PRIMARY KEY (componentId)
, name VARCHAR(50) NOT NULL
)

CREATE TABLE membership (
compositeId INT NOT NULL
CONSTRAINT XFK01membership
FOREIGN KEY (compositeId)
REFERENCES composite (compositeId)
, componentId INT NOT NULL
CONSTRAINT XFK02membership
FOREIGN KEY (componentId)
REFERENCES component (componentId)
CONSTRAINT XPKmembership
PRIMARY KEY (compositeId, componentId)
)This allows you to have many composites (packages), made up of many components (parts), and allows each component to appear in as many packages as needed (because the membership relationship is separate from both the component and the composite).

The ERD diagram questions are a bit more complex. Using IDE1FX, any attribute "above the line" is part of the primary key. You can optionally tag the foreign key attributes with an (FK) designator. Using "crows foot" notation, any attribute "above the line" is also part of the primary key, but there is no standard way to denote foreign keys. Using the various GUI tools for UML, the rules vary.

-PatP|||USE Northwind
GO

CREATE TABLE myTable00(Col4 int NOT NULL PRIMARY KEY)

CREATE TABLE myTable99 (
Col1 int IDENTITY(1,1)
, Col2 char(1)
, Col3 datetime DEFAULT GetDate()
, Col4 int
, PRIMARY KEY (Col1, Col2)
, FOREIGN KEY (Col4) REFERENCES myTable00(Col4)
)
GO

DROP TABLE myTable99
DROP TABLE myTable00
GO|||Hello, Pat and Brett:

Thanks a lot for the posts. Let's share this code I got it from email.

create table addresses (
houseNum INT,
telNo INT,
constraint pk_address primary key (houseNum, telNo)
)|||I'm not clear on why you are sharing that. What would you like us to do with it?

-PatP