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
- What’s the best way to search for a UPC code in a Database?
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- What is the difference between UNION and UNION ALL?
- Case in Select Statement
- ORA-00904: invalid identifier
- SQL WITH clause example [duplicate]
- Inserting multiple rows in a single SQL query? [duplicate]
- Unknown column in ‘field list’ error on MySQL Update query
- Unknown column in ‘field list’ error on MySQL Update query
- SQL Inner-join with 3 tables?
- The wait operation timed out. ASP
- What is SELF JOIN and when would you use it? [duplicate]
- The wait operation timed out. ASP
- Conversion failed when converting date and/or time from character string while inserting datetime
- how to fix oracle ORA-01722 invalid number error
- MySQL – Operand should contain 1 column(s)
- SQL SELECT WHERE field contains words
- Conversion failed when converting date and/or time from character string while inserting datetime
- MySQL “CREATE TABLE IF NOT EXISTS” -> Error 1050
- Insert Data Into Temp Table with Query
- MySQL Error: : ‘Access denied for user ‘root’@’localhost’
- MySQL create table if not exists and insert record only if table was created
- error, string or binary data would be truncated when trying to insert
- How to create Temp table with SELECT * INTO tempTable FROM CTE Query
- NOT IN vs NOT EXISTS
- SQL SELECT WHERE field contains words
- Online SQL Query Syntax Checker
- Must declare the scalar variable
- ORA-00979 not a group by expression
- ORA-00907: missing right parenthesis
- How do I use properly CASE..WHEN in MySQL
- Must declare the scalar variable
- Why do we need “Relationships” between tables at all?
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server
- Using group by on multiple columns
- How to turn IDENTITY_INSERT on and off using SQL Server 2008?sql-server-2008
- How to delete duplicate rows in SQL Server?
- How can I do a FULL OUTER JOIN in MySQL?
- Nested select statement in SQL Server
- INSERT statement conflicted with the FOREIGN KEY constraint – SQL Server