www.quwoool.com
New Member
I am pretty new to SQL. But really want to learn as much as possible. However, I really have something I need to do for work (kind of got thrown into it). But I keep running into road blocks. I need to create a table that always has update information from this stored procedure I created. I initially tried joining tables, etc but just couldn't get the exact data I needed. The best way I have found so far to accomplish at least gathering the correct data is to use this stored procedure. However, here comes another road block; putting it in a table. The reason I need a table is because an external application (one that is being developed for our location) needs to have this table to view certain information. It will look at this table several times a day because the data may change. I would greatly appreciate any help or advice that may lead me to the solution I need. Thank you in advance. Here is the stored procedure I have now. (I would of loved to had been able to just use this to create a view but of course I can't because of the variable declaration)\[code\] DECLARE @now DATETIME SET @now = CONVERT(VARCHAR(8),GETDATE(),108) IF @now BETWEEN '06:40:00' AND '14:39:59' SELECT t.ProductionDate, t.Shift, t.LineNumber, t.Cart, t.CavityPosition, t.ProgramNumber, t.PartNumber,t.Cavity FROM tblTransactionDetail t JOIN tblLPCurrentOnline c on t.Cart=c.Fixture AND t.ProgramNumber=c.Program AND t.LineNumber=c.Linenumber WHERE Shift = 1 and PartNumber <>'' ELSE IF @now BETWEEN '14:40:00' AND '22:39:59' SELECT t.ProductionDate, t.Shift, t.LineNumber, t.Cart, t.CavityPosition, t.ProgramNumber, t.PartNumber,t.Cavity FROM tblTransactionDetail t JOIN tblLPCurrentOnline c on t.Cart=c.Fixture AND t.ProgramNumber=c.Program AND t.LineNumber=c.Linenumber WHERE Shift = 2 AND PartNumber <>''ELSE IF @now BETWEEN '22:40:00' AND '24:59:59' OR @now BETWEEN '00:00:00' AND '06:39:59' SELECT t.ProductionDate, t.Shift, t.LineNumber, t.Cart, t.CavityPosition, t.ProgramNumber, t.PartNumber,t.Cavity FROM tblTransactionDetail tJOIN tblLPCurrentOnline con t.Cart=c.FixtureAND t.ProgramNumber=c.ProgramAND t.LineNumber=c.Linenumber WHERE Shift = 3 AND PartNumber <>'' \[/code\]