Try:
With DependencedIncidents AS ( SELECT INC.[RecTime],INC.[SQL] AS [str] FROM ( SELECT A.[RecTime] As [RecTime],X.[SQL] As [SQL] FROM [EventView] AS A CROSS JOIN [Incident] AS X WHERE patindex('%' + A.[Col] + '%', X.[SQL]) > 0 ) AS INC ), lalala AS ( SELECT INC.[RecTime],INC.[SQL] AS [str] FROM ( SELECT A.[RecTime] As [RecTime],X.[SQL] As [SQL] FROM [EventView] AS A CROSS JOIN [Incident] AS X WHERE patindex('%' + A.[Col] + '%', X.[SQL]) > 0 ) AS INC )
And yes, you can reference common table expression inside common table expression definition. Even recursively. Which leads to some very neat tricks.
Related Posts:
- T-SQL split string based on delimiter
- How can I group by date time column without taking time into consideration
- Arithmetic overflow error converting varchar to data type numeric. ’10’ <= 9.00
- Varchar invalid for Sum operator
- Selecting COUNT(*) with DISTINCT
- What is a stored procedure?
- Self Join to get employee manager name
- How do I UPDATE from a SELECT in SQL Server?
- SQL query to select dates between two dates
- When should I use CROSS APPLY over INNER JOIN?
- How can I do an UPDATE statement with JOIN in SQL Server?
- T-SQL split string
- Rename column SQL Server 2008
- Efficiently convert rows to columns in sql server
- SQL Query with NOT LIKE IN
- How do I escape a single quote in SQL Server?
- How do I escape a single quote in SQL Server?
- IDENTITY_INSERT is set to OFF – How to turn it ON?
- Column name or number of supplied values does not match table definition
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- SQL Server FOR EACH Loop
- SQL Server WITH statement
- DateTime2 vs DateTime in SQL Server
- SQL Server Insert if not exists
- SQL Server: Invalid Column Name
- How can I get column names from a table in SQL Server?
- How do I do multiple CASE WHEN conditions using SQL Server 2008?
- How to parse XML data in SQL server table
- What is the equivalent of ‘describe table’ in SQL Server?
- Error converting data type varchar to float
- Arithmetic overflow error converting numeric to data type numeric
- I want to use CASE statement to update some records in sql server 2005
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Determine ROW that caused “unexpected end of file” error in BULK INSERT?
- Sql query to insert datetime in SQL Server
- Conversion failed when converting the varchar value ‘simple, ‘ to data type int
- SELECT DISTINCT on one column
- Exclude a column using SELECT * [except columnA] FROM tableA?
- Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 1, column 4 (Year)
- TSQL PIVOT MULTIPLE COLUMNS
- Microsoft OLE DB Provider for SQL Server error ‘80004005’
- Bulk load data conversion error (truncation)
- SQL “select where not in subquery” returns no results
- Equivalent of Oracle’s RowID in SQL Server
- Get current year in TSQL
- Is it possible to specify condition in Count()?
- SQL Server dynamic PIVOT query?
- Backup a single table with its data from a database in sql server 2008
- Error converting data type varchar
- Temporary table in SQL server causing ‘ There is already an object named’ error
- I want to use CASE statement to update some records in sql server 2005
- How to calculate age (in years) based on Date of Birth and getDate()
- ORDER BY items must appear in the select list if SELECT DISTINCT is specified
- Text was truncated or one or more characters had no match in the target code page including the primary key in an unpivot
- “select * into table” Will it work for inserting data into existing table
- SUM OVER PARTITION BY
- Filter data based on date in sql
- Update query using Subquery in Sql Server
- Unknown column in ‘field list’ error on MySQL Update query
- How to create Temp table with SELECT * INTO tempTable FROM CTE Query
- Using group by on multiple columns
- Nested select statement in SQL Server
- What’s the difference between VARCHAR and CHAR?
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- How to split the name string in mysql?
- Sql Server equivalent of a COUNTIF aggregate function
- Simple PHP Pagination script
- ORA-12560: TNS:protocol adaptor error
- SQL – HAVING vs. WHERE
- What’s the difference between RANK() and DENSE_RANK() functions in oracle?
- Operand type clash: int is incompatible with date + The INSERT statement conflicted with the FOREIGN KEY constraint
- How to SUM two fields within an SQL query
- Difference between numeric, float and decimal in SQL Server
- “ORA-01438: value larger than specified precision allowed for this column” when inserting 3
- ERROR: there is no unique constraint matching given keys for referenced table “bar”
- How do I query for all dates greater than a certain date in SQL Server?
- Cast from VARCHAR to INT – MySQL
- Using RegEx in SQL Server
- Must declare the scalar variable
- postgresql: error duplicate key value violates unique constraint
- Is there a workaround for ORA-01795: maximum number of expressions in a list is 1000 error?
- ORA-06502: PL/SQL: numeric or value error: character string buffer too small
- Insert into a MySQL table or update if exists
- Convert timestamp to date in Oracle SQL
- Update statement with inner join on Oracle
- How to write a foreach in SQL Server?
- What does Include() do in LINQ?
- SQL Server “cannot perform an aggregate function on an expression containing an aggregate or a subquery”, but Sybase can
- Get everything after and before certain character in SQL Server
- LEFT function in Oracle
- Comma separated results in SQL
- SQLite string contains other string query
- Cannot insert explicit value for identity column in table ‘table’ when IDENTITY_INSERT is set to OFF
- WordPress SQL LIKE request doesn’t work for fields with special symbols
- Better way to migrate to server?
- WordPress can I manually add columns in users table and display it in the default manage user plugin and registration form? [closed]
- Help me SELECT thumbnail from SQL and use
- Why is my insert row only inserting the final row from the loop into the database rather than just inserting one
- Creating a “forum” – showing last post or last commented post
- Replace Unwanted Space in Post Content URL