Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>DECLARE @Document_Text TABLE(UserID INT , DocText_ID INT , DocURL NVARCHAR(100),DocText NVarchar(4000)) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (1,1,'Blah','Ceo blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (2,1,'Blah','blah blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (3,1,'Blah','blah blah Manager blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (4,1,'Blah','blah blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (5,1,'Blah','blah blah blah blah blah time time time') INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (6,1,'Blah','Cblah blah blah blah blah time time time') INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (7,1,'Blah','Cblah blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (8,1,'Blah','blah Ceo blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (9,1,'Blah','blah blah blah blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (10,1,'Blah','blah blah Programmer blah blah time time time' ) INSERT INTO @Document_Text (UserID , DocText_ID , DocURL,DocText) VALUES (11,1,'Blah','blah blah blah blah blah time time time' ) DECLARE @JobRole TABLE (JR_ID INT , JobRole NVARCHAR(50)) INSERT INTO @Jobrole (JR_ID , JobRole ) VALUES (1,'Programmer') INSERT INTO @Jobrole (JR_ID , JobRole ) VALUES (2,'Ceo') INSERT INTO @Jobrole (JR_ID , JobRole ) VALUES (3,'Manager') SELECT JobRole,DT.DocText_ID, SUBSTRING(DT.DocText, CHARINDEX(JobRole, DT.DocText)-125, 250) as SubText FROM @Document_Text DT CROSS JOIN @JobRole JR WHERE DT.DocText like '%'+ JobRole +'%'' </code></pre> <p>I included table variables so as you can see my thinking. Is this what you were looking for. It avoids cursors but I don't know how well it would scale.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload