natx

Greenhorn
+ Follow
since Aug 13, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by natx

could someone help me please?
Although the following triggers dont give me any syntax error. Every time a user inserts or updates a record, the region field in the member table is set to NULL.
This is the code:
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
DECLARE @userid integer, @country nvarchar
SELECT @userid = member.userid, @country = member.country
FROM inserted, member
IF @userid = member.userid
BEGIN
UPDATE [member]
SET region = Region.area
FROM Region
WHERE Region.country = member.country
END
------------------------------------
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
SELECT i.userid = m.userid
FROM inserted i, member m
IF i.userid = m.userid
BEGIN
UPDATE [member]
SET region = Region.area
FROM Region
WHERE Region.country = member.country
END
---------------------------------------
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
UPDATE [member]
SET member.region = Region.area
FROM
[member]
JOIN Region ON Region.country = member.country
JOIN inserted ON inserted.userid = member.userid
Thanks so much
natalia http://www.nataliaz.com
i have the following trigger which inserts the region field into the member table every time a user registers or updates their personal details through the website.
CREATE TRIGGER [regiontree] ON [member]
FOR INSERT, UPDATE
AS
UPDATE member SET region = Region.region FROM Region WHERE member.country = Region.country
However i have been told that to this trigger will update all the rows in the table every time.
How can i make this trigger to select one single row?
the member table has the unique identidier memberid.
The Region table doesnt have any unique identifier, it only contains two fields (region and country) and a fixed number of records (50 countries and 15 regions).
Many thanks for any help
Natalia http://www.nataliaz.com
I think i understand what you want to do, but as i explained in my email this is my second day using ms sql server, and i wouldnt know where to stick all the code, i was thinking i could sort my problem out along these lines
CREATE PROCEDURE users_date
@MyDate DateTime
AS
DECLARE @DateOnly DateTime
SELECT @DateOnly = CONVERT(DateTime,CONVERT(VARCHAR(8),@MyDate,103))
SELECT *
FROM Members, Activity
WHERE cp_date = @DateOnly
(although i dont know how to connect the procedure with the two date fields in my two tables). Thanks for your help.
I just started working with MS SQL Server, i imported my database from MS Access, and now i would like to set the date to a default dd/mm/yy without the time and the 4 digits in the year.
I have used getdate()but this gives me full date and time.
How can i achieve this?
Many thanks for any help.