Search Results

Search found 2 results on 1 pages for 'spidermain50'.

Page 1/1 | 1 

  • SQL SELECT from third level table

    - by Spidermain50
    Ok I know little about SQL so bare with me... I'm trying to see if certain values exist in a third level table and I don't know how to go about it. Here is the scenario... I have a Accident table that holds accident information. It has 3 one-to-many child tables (Units, Occupants, NonMotorists). An each of those child tables have their own many-to-many child table (Alcohol). I need to be able to have some way of seeing if a range of values exists in a field in those Alcohol tables. Here is watered down version of what my structure for the tables looks like... --tblAccident--_ PK_AccidentNumber --tblAccidentUnit-- PK_PrimaryKey FK_AccidentNumber --tblAccidentOccupant-- PK_PrimaryKey FK_AccidentNumber --tblAccidentNonMotorist-- PK_PrimaryKey FK_AccidentNumber --tblAccidentUnitAlcohol-- PK_PrimaryKey FK_ForeignKey AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH --tblAccidentOccupantAlcohol-- PK_PrimaryKey FK_ForeignKey AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH --tblAccidentNonMotoristAlcohol-- PK_PrimaryKey FK_ForeignKey AlcoholValue <---- THIS IS WHAT I NEED TO SEARCH I hope this makes some sense as to what i am trying to accomplish. thank you

    Read the article

  • SQL 2000 Multiple IF Statements

    - by Spidermain50
    I get a error when I try to use multiple IF statements. This is the error... "Msg 156, Level 15, State 1, Procedure fnTNAccidentIndicator, Line 81 Incorrect syntax near the keyword 'END'." This is the structure of my code... USE SS_TNRecords_Accident SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION dbo.fnTNAccidentIndicator ( @inAccidentNumber nvarchar, @inIndicatorMode int ) RETURNS nvarchar AS BEGIN DECLARE @AlcoholInd nvarchar DECLARE @DrugInd nvarchar DECLARE @SpeedInd nvarchar DECLARE @ReturnValue nvarchar SET @AlcoholInd = '1' SET @DrugInd = '2' SET @SpeedInd = '3' SET @ReturnValue = 'N' IF (@inIndicatorMode = @AlcoholInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END IF (@inIndicatorMode = @DrugInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END IF (@inIndicatorMode = @SpeedInd) BEGIN --select statment IF (@@ROWCOUNT > 0) BEGIN @ReturnValue = 'Y' END END Return @ReturnValue END GO

    Read the article

1