User Profile

Collapse

Profile Sidebar

Collapse
Quish
Quish
Last Activity: May 2 '08, 01:23 PM
Joined: Jan 11 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Quish
    replied to Constraint Triggers
    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...
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Constraint Triggers
    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)
    ...
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Constraint Triggers
    i missed keyword "AS" between "Instead of Insert, Update" and "Begin".
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Constraint Triggers
    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_ID
    ...
    See more | Go to post
    Last edited by Quish; May 1 '08, 04:15 PM. Reason: 'AS' missing from code

    Leave 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

    Quish
    See more | Go to post

    Leave a comment:


  • Quish
    started a topic Constraint Triggers

    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...
    See more | Go to post

  • Quish
    started a topic Creating multiple stored procedures at once

    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...
    See more | Go to post

  • tenant_id is a INT datatype
    See more | Go to post

    Leave a comment:


  • 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 JOIN
    ...
    See more | Go to post

    Leave a comment:


  • Hi There

    This returns 6 identical records apart for tenant_id which is repeated 3 times for each ID

    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
    This is my second attempt but returns 2 identical records apart for...
    See more | Go to post

    Leave a comment:


  • Quish
    started a topic Selecting all from Super-Types and Sub-Types

    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...
    See more | Go to post

  • Quish
    replied to Sum and Count in a Query
    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
    ...
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Sum and Count in a Query
    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
    ...
    See more | Go to post

    Leave a comment:


  • Quish
    started a topic Sum and Count in a Query

    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....
    See more | Go to post

  • Quish
    replied to Sequences in MS Server
    Thanks for the help,

    Quish
    See more | Go to post

    Leave a comment:


  • Quish
    started a topic Sequences in MS Server

    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.
    ...
    See more | Go to post

  • Quish
    replied to Common Dialog Control Error
    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 again
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Common Dialog Control Error
    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.
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Common Dialog Control Error
    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...
    See more | Go to post

    Leave a comment:


  • Quish
    replied to Common Dialog Control Error
    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....
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...