I have asked this over at Stackoverflow but with no luck :-(

I have two tables. One, tableX, that gets values from a PLC and one, tableY, that hold text strings. I need to populate a third table with rows of only the records that have a specific value, 1, in tableX and combined with their respective text labels from tableY

tableX has columns mapped to all relevant tags in the PLC plus a timestamp column getdate() ie when a tag in the PLC shift to 1 it will create a record in tableX with a timestamp and a 1 in the corresponding cell.


timestamp INFO00_1 INFO00_2 INFO00_3 INFO00_4
getdate() Cell 1 Cell 2 Cell 3 Cell 4

tableY has two columns no and name. Here records consist of the text string and no. The no column is also a text. like this.


no name
INFO00_1 some text string
INFO00_0 some text string

I am faily new to SQL so I bear with me. I think that i can use a stored procedure to create a temp table that gets updated whenever there is a new record in tableX and then use this table to populate a tableZ adding the no eg INFO00_1 to the record. like this


no timestamp name
INFO00_1 getdate() some text string

Hopefully this makes sense and is doable, otherwise I am in trouble

  • 3
    Are you sure you need a table? Would a View do instead? Anyway, please see Help me write this query in SQL for query-writing questions.
    – vonPryz
    Commented Nov 3, 2022 at 8:54
  • @vonPryz Thanks for the link. I am not sure about much when it comes to SQL :-) as I understand it a view is temporary and data only exist when queried? if this is the case I need a table since I have some regulations (FDA) that I need to satisfy.
    – vito
    Commented Nov 3, 2022 at 9:56
  • 3
    Please edit the question and include regulatory requirements and whatnot there too. Comments are ephemeral, and not suitable for details.
    – vonPryz
    Commented Nov 3, 2022 at 10:11

1 Answer 1


Made it work with a little help from google and some fiddling


Question closed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.