I have the following in a dataset --Yeild - 15 Points - (3/6) And to do a calculation I need to pull the 3 position out of the ( ) section. It also has a capability of being something like the following --Yeild - 15 Points - (10/12) instead. Any ideas on how I would go about this?
That is put into a dataset b/c of the following Dataset (which I had a lot of help on b/c I'm still lost on Cast). However I'm just curious if anyone knows How I can pull this # out thanks.
CREATE PROCEDURE dbo.sp_Goals_GetPlantGoalsReviewPage
@dotnet.itags.org.CompanyID nvarchar(2), @dotnet.itags.org.FacilityID nvarchar(2)
AS
DECLARE @dotnet.itags.org.StartMonth int, @dotnet.itags.org.EndMonth int
SELECT @dotnet.itags.org.StartMonth = StartMonth, @dotnet.itags.org.EndMonth = EndMonth FROM Period WHERE PeriodID = dbo.fn_GetCurrentPeriod(@dotnet.itags.org.CompanyID, @dotnet.itags.org.FacilityID)
DECLARE @dotnet.itags.org.Column nvarchar(1000)
DECLARE @dotnet.itags.org.i int
SET @dotnet.itags.org.i = @dotnet.itags.org.StartMonth
SET @dotnet.itags.org.Column = 'Cast(GoalMByte' + Cast(@dotnet.itags.org.i AS nvarchar(100)) + ' AS int)'
WHILE @dotnet.itags.org.i < @dotnet.itags.org.EndMonth
BEGIN
SET @dotnet.itags.org.i = @dotnet.itags.org.i + 1
SET @dotnet.itags.org.Column = @dotnet.itags.org.Column + ' + Cast(GoalMByte' + Cast(@dotnet.itags.org.i AS nvarchar(100)) + ' AS int)'
END
DECLARE @dotnet.itags.org.Query nvarchar(2000)
SET @dotnet.itags.org.Query = ('SELECT [Description] + '' - '' + Cast(Points AS nvarchar(100)) + '' Points - ('' + Cast(' + @dotnet.itags.org.Column + ' AS nvarchar(100)) +''/' + Cast(@dotnet.itags.org.i AS nvarchar(100)) + ')'' AS PlantGoals,Points ,' + @dotnet.itags.org.Column + '/' + Cast(@dotnet.itags.org.i AS nvarchar(100)) + 'AS Fraction
FROM Goals
WHERE CompanyID = ''' + @dotnet.itags.org.CompanyID + ''' AND FacilityID = ''' + @dotnet.itags.org.FacilityID + ''' AND PeriodID = ' + Cast(dbo.fn_GetCurrentPeriod(@dotnet.itags.org.CompanyID, @dotnet.itags.org.FacilityID) AS nvarchar(100)) + ' AND GoalCategory = ''Plant''')
EXEC (@dotnet.itags.org.Query)lets say you create a string that contains the whole string from the DB
dim strAll as string = DBRecord 'Assuming output will be something like: Yeild - 15 Points - (3/6)
Now you can tokenize the string into 3 distinct parts (Yield , 15 points, and (3/6) )
dim strTokens as string() = strAll.split("-"c)
Now to reference the (3/6) portion you can:
dim strFoo as string = strTokens(2)
Now you can split, trim all you like with just that part. :)
Sweet thanks -- I'll give it a shot.
i couldn't tell from your post if the '-' character was a hyphen or a minus sign if its a minus, (ie part of the data) split based on " " the space character
worked great thanks!
0 comments:
Post a Comment