1 Corinthians 11:23-29: "23 For I received from the Lord what I also delivered to you, that the Lord Jesus on the night when he was betrayed took bread, 24 and when he had given thanks, he broke it, and said, 'This is my body which is for you. Do this in remembrance of me.' 25 In the same way also he took the cup, after supper, saying, 'This cup is the new covenant in my blood. Do this, as often as you drink it, in remembrance of me.' 26 For as often as you eat this bread and drink the cup, you proclaim the Lord's death until he comes.
"27 Whoever, therefore, eats the bread or drinks the cup of the Lord in an unworthy manner will be guilty concerning the body and blood of the Lord. 28 Let a person examine himself, then, and so eat of the bread and drink of the cup. 29 For anyone who eats and drinks without discerning the body eats and drinks judgement on himself."
Luke 5:31-32: "31 And Jesus answered them, 'Those who are well have no need of a physician, but those who are sick. 32 I have not come to call the righteous but sinners to repentance.'"
Mark 2:17: "And when Jesus heard it, he said to them, 'Those who are well have no need of a physician, but those who are sick. I came not to call the righteous, but sinners.'"
1 Corinthians 10:16: "The cup of blessing that we bless, is it not a participation in the blood of Christ? The bread that we break, is it not a participation in the body of Christ?"
Romans 11:33-36: "33 Oh, the depth of the riches and wisdom and knowledge of God! How unsearchable are his judgements and how inscrutable his ways! 34 "For who has known the mind of the Lord, or who has been his counselor?" 35 "Or who has given a gift to him that he might be repaid?" 36 For from him and through him and to him are all things. To him be glory forever. Amen."
+++
The text is public domain:
Your table I approach;Dear Savior, hear my prayer.Let not an unrepentant heartProve hurtful to me there.
Lord, I confess my sinsAnd mourn their wretched bands;A contrite heart is sure to findForgiveness at Your hands.
Your body and Your blood,Once slain and shed for me,Are taken at Your table, Lord,In blest reality.
Search not how this takes place,This wondrous mystery;God can accomplish vastly moreThan what we think could be.
O grant, most blessèd Lord,That earth and hell combinedMay not about this sacramentRaise doubt within my mind.
Oh, may I never failTo thank You day and nightFor Your true body and true blood,O God, my peace and light.
+++
The two passages from 1 Corinthians are the main sources for the hymn and appear most clearly in the first and third verses. 1 Corinthians 11:27-29 in particular appears in the second half of the first verse: "Let not an unrepentant heart / Prove hurtful to me there."
Luke 5:31-32 and Mark 2:17 seem to be in the background of the second verse, but the hymn text bears more resemblance to Psalm 51:17: "The sacrifices of God are a broken spirit; a broken and contrite heart, O God, you will not despise."
The passage from Romans informs the fourth verse: "Search not how this takes place... God can accomplish vastly more / Than what we think could be."
"Day and night" in the last verse is a merism.