behenkaloda
Starting Member
1 Post |
Posted - 2012-01-20 : 19:03:11
|
Hi guyz, I am stuck and dont know how to do this.I need a stored procedure to take the following input:@input varchar(50) = ‘210,0,10,3100’@AilmentID INT = 1234Parse input into individual values: 2100103100Look up the MeasurementID for those values which are stored in the “abbreviation” column of the Measurement table.The first value in the list is a specific type of data with DataPointID = 692nd value DataPointID = 703rd value DataPointID = 764th value DataPointID = 74Now I need to check and see if there is a record in the AilmentAssay table with the supplied AilmentID and DataPointID.If yes, then update that value to the new MeasurementID just looked up.If no, insert a row into the AilmentAssay table with the new AilmentId, DatapointID and MeasurementIDHere are the tables and data:CREATE TABLE [dbo].[AilmentAssay]([AilmentAssayID] [int] IDENTITY(0,1) NOT NULL,[AilmentID] [int] NOT NULL,[DataPointID] [int] NOT NULL,[MeasurementID] [int] NOT NULL)GOCREATE TABLE [dbo].[Measurement]([MeasurementID] [int] IDENTITY(0,1) NOT NULL,[Description1] [varchar](200) NOT NULL,[Abbreviation] [varchar](50) NOT NULL)INSERT INTO dbo.Measurement (Description1 ,Abbreviation)VALUES ('1+, 20%', '120'),('2+, 50%', '250'),('15 - 20%','15-20'),('10%','10'),('3+, 100%', '3100'),('0%', '0'),('2+, <10%','2<10')CREATE TABLE [dbo].[MeasurementTypeAssoc]([MeasurementTypeAssocID] [int] IDENTITY(1,1) NOT NULL,[MeasurementID] [int] NOT NULL,[CodeTypeID] [int] NOT NULL)INSERT INTO dbo.MeasurementTypeAssoc( MeasurementID ,CodeTypeID)VALUES ( 1,188),(2,188), (3,188),(4,188),(5,188),(6,188),(7,188)The MeasurementTypeAssoc table pulls the records from the Measurement table that are candidates for this lookup.-- thanks, if u can help meREGARDS,Behenkaloda |
|