got there in the end
thanks you all your help
create Trigger Tenant_room_che ck On Tenant
Instead Of Insert
AS
Begin
Declare
@Tenant_Count Int
,@Bedroom_Count Int
,@HOUSE_ID INT
Select @Tenant_Count = Count(Distinct T.Tenant_ID)
From Tenant T
where T.House_ID = @House_ID
and Tenant_status = 1...
User Profile
Collapse
-
Even with the amendment of AS i am still getting problems.
after some thinking regarding what i actually wanted the trigger to do i created this based on the previous examples.
...Code:ALTER Trigger Tenant_room_check On Tenant Instead Of Insert, Update AS Begin Declare @Tenant_Count Int ,@Bedroom_Count Int Select @Tenant_Count = Count(Distinct T.Tenant_ID)Leave a comment:
-
i missed keyword "AS" between "Instead of Insert, Update" and "Begin".Leave a comment:
-
A friend gave me some pointers and i have come up with this
...Code:Create Trigger Tenant_room_check On Tenant Instead Of Insert, Update Begin Declare @Tenant_Count Int ,@Bedroom_Count Int Select @Tenant_Count = Count(Distinct T.Tenant_ID) From Tenant T Inner Join Inserted I On T.TenantID = I.TenantID And T.House_IDLeave a comment:
-
I got the answer -
i needed a 'go' between each stored procedure
create proc p1 as
select 1
go
create proc p2 as
select 2
Many Thanks
QuishLeave a comment:
-
Constraint Triggers
Hello all
The majority of my database experience comes from ORACLE and i am trying to use some functionality that i have already used in Oracle into a project i am working on in MSDE.
I want to create a trigger that uses a DML constraint that will prevent a tenants from being inserted into a house if the bedroom count is less or equal to the number of tenants currently in the house.
The oracle code is... -
Creating multiple stored procedures at once
Hey
I am creating a database application that is accessed through a .NET front end.
What I want to do is run a SQL script that will create my DB, create my indexes and enforce my constraints (all of which I have done) but I also want to create my stored procedures in the same script also.
When I merge all my stored procedures (about 16) into one file and run it in SQL Query Analyser I get multiple errors but... -
-
Hey there
I know its been a while but I have been up to different things.
I have been trying what you said about using the inner joins and have come up with this but no rows are being returned
...Code:SELECT TENANT.*, STUDENT.*, PROFESSIONAL.* FROM TENANT INNER JOIN STUDENT ON TENANT.TENANT_ID = STUDENT.TENANT_ID INNER JOINLeave a comment:
-
Hi There
This returns 6 identical records apart for tenant_id which is repeated 3 times for each ID
This is my second attempt but returns 2 identical records apart for...Code:select distinct * from tenant t, student s, professional p, house h where t.tenant_ID = s.tenant_ID and t.house_id = 1 or t.tenant_ID = p.tenant_ID and t.house_id = 1
Leave a comment:
-
Selecting all from Super-Types and Sub-Types
Hi There
I am wanting to create a query that will select all entries from all tables within a super and sub types that are linked to a house using house_id in table tenant house_id.
my tables are
Tenant - super-type - PK tenant_id
Professional - sub-type - PK-FK tenant_id
Student - sub-type - PK-FK tenant_id
I keep getting multiple rows displaying the same values even though... -
I have found that i can separate the SQL statements by a semicolon but I can imagine that this makes bad SQL and is not very performance friendly as it makes several result tables,any suggestions how would I improve it? This is what I have so far
...Code:SELECT H.* FROM HOUSE H WHERE H.HOUSE_ID = 2; SELECT COUNT(R.ROOM_NAME) AS Rooms FROM HOUSE
Leave a comment:
-
Here is the create script
...Code:IF EXISTS(SELECT name FROM abacus..sysobjects WHERE name = 'OWNER') DROP TABLE OWNER CREATE TABLE OWNER (OWNER_ID INT IDENTITY(1,1) NOT NULL Primary KEY ,OWNER_NAME VARCHAR(50) ,OWNER_ADDRESS1 VARCHAR(50) ,OWNER_ADDRESS2 VARCHAR(50) ,OWNER_ADDRESS3 VARCHAR(50) ,OWNER_POSTCODE VARCHAR(50) ,OWNER_HOUSE_ID INT ) IF EXISTS(SELECT
Leave a comment:
-
Sum and Count in a Query
Hi
I have a general database question, that will effect the output from my database to a form which is being developed in .NET, it may seem very simple but I cannot make head nor tail from it.
I need to create a SELECT statement that will select all data from a table called HOUSE, but also count the number of instances of the word "BEDROOM" from a table ROOM which is linked to HOUSE through a link table HOUSE_ROOM.... -
-
Sequences in MS Server
Hello all,
I am having some trouble with functions and triggers within MSDE; the majority of my database experience comes from Oracle and I want to implement similar functions and trigger used in Oracle within MS Server.
I am trying to create a sequence on an ID that reference the last ID (before insert) in a table and then increments by 1 to create the next number in the sequence to act as a primary key.
... -
THANKS for all the help. I managed to solve the problem by creating a dummy form with a Common Dialog Control and basic file browse function. I then loaded that along with the rest of the database onto the other system, from there I recreated the form I needed using the dummy form on the second system and it now works! Though I still don’t know why the form/code did not work in the first place. Ah well – All’s well that ends well. Thanks againLeave a comment:
-
Thanks for you help but I’m sorry to say that the problem is still not fixed. Is their any setting within Access, which may prevent the ActiveX controls from working?
The reason why I say this is because I have another totally separate database application on both systems, which uses the same ActiveX control and it works perfectly.Leave a comment:
-
Thank You, after reading you post I was slightly optimistic about getting this issue sorted but after having transferred the "COMDLG32.o cx" file used on my system and placed it in the system32 folder on the other system, but the problem still remains. I also matched the other systems references to those of the working system, but still no joy.
I also took a look at the file from the link you gave me, but it’s too complex...Leave a comment:
-
I would very much like to install VB 6 on the other systems, but then there is the small issue of licences that would need to be considered, which i do not have....Leave a comment:
No activity results to display
Show More
Leave a comment: