Fix SQL Server CTE Maximum Recursion Exhausted Error
To prevent that, SQL Server set the default value of the recursion level ... FROM Split WHERE endpos > 0 ) SELECT 'Value' = SUBSTRING(@String,stpos,COALESCE(NULLIF(endpos,0),LEN(@String)+1)-stpos)...
View ArticleT-SQL Using a @variable in WHERE IN ( @varname )
Ok, I'm screwing this up again and I'm not understanding why. (continued from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/545009008831 as this is really a new topic) I don't think...
View ArticleExtracting Deadlock information using SYSTEM_#Health Extended Events
It keeps historical system health information of the SQL Server instance. Today ... errorlog WHERE [Text] LIKE 'Logging%MSSQL\Log%'; DROP TABLE #errorlog; SET @path = SUBSTRING(@tag, 38,...
View ArticleConvert a string array to tabular data in SQL Server
If you use SQL Server for any considerable amount of time, you'll likely encounter a situation in which it would be very useful to pass an array of values into a function or procedure and handle data...
View Article6.1 Consuming a Gateway Service in JavaScript
getModel()).substring(0.type.property[j].setModel(oModel.property[j ... or other items contained within this material.S. DB2 Connect. SQL Anywhere. AIX. HACMP. and MultiWin are trademarks or registered...
View ArticleExecute immediate and passing clob as a parameter is not working.
FROM sysadm.mpulktm1@to_bscsprd_rpt m1 WHERE tmcode IN ( SELECT tmcode FROM sysadm.rateplan@to_bscsprd_rpt WHERE shdes IN ( SELECT REGEXP_SUBSTR (v_tmcode_list ... in the clob).I am executing from sql...
View ArticleOracle: Quilting Consistent ASCIISTR Hexadecimal Ouput
Last time, I noted that Oracle 12c's SQL function called ASCIISTR produces inconsistent output. For example, WITH t AS ( SELECT unistr( '\0075\0078\0079\0080\0085\0085' ) instring FROM dual ) SELECT...
View ArticleIntroduction to Liquibase and Managing Your Database Source Code
In previous posts I showed how you can manage SQL scripts lifecycle with the help of Oracle Developer ... a_end_pos integer ) return varchar2 is begin return substr( a_string, a_start_pos, a_end_pos -...
View ArticleSQL Tip: Returning a portion of a string field – dynamically (CHARINDEX)
I've decided to add these SQL Tips to my external blog ... The “LEFT”, “RIGHT”, or “SUBSTRING” functions can do this easily. The LEFT function will return the number of characters specified from the...
View ArticleT-SQL Using a @variable in WHERE IN ( @varname )
Ok, I'm screwing this up again and I'm not understanding why. (continued from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/545009008831 as this is really a new topic) I don't think...
View ArticleCreate custom looping procedures in SQL Server 2005
In my previous SQL Server article, I discussed how you can use two undocumented ... declare @tempindex int if (substring(@cmd, @replacecharindex - 1, 1) = N'''') begin /* if ? is inside of '', we need ...
View Article6.1 Consuming a Gateway Service in JavaScript
getModel()).substring(0.type.property[j].setModel(oModel.property[j ... or other items contained within this material.S. DB2 Connect. SQL Anywhere. AIX. HACMP. and MultiWin are trademarks or registered...
View ArticleUnicode: Not Just For International Breakfasts Anymore
David Ballantyne's winning SQL Server query used VARBINARY data type ... 0075\0078\0079\0080\0085\0095\0410\041A\0410\0420\9999\FFFF') instring FROM dual ) SELECT LEVEL r# , SUBSTR(instring,LEVEL,1) as...
View Article#Web Screen Scraping with Python to Populate SQL Server Tables
SQL Server is great at storing data ... extract author name from h1 tags -- and assign to local variable declare @author varchar(50) = ( select substring ( line ,charindex('',line)+4...
View ArticleCreate custom looping procedures in SQL Server 2005
In my previous SQL Server article, I discussed how you can use two undocumented ... declare @tempindex int if (substring(@cmd, @replacecharindex - 1, 1) = N'''') begin /* if ? is inside of '', we need ...
View ArticleExecute immediate and passing clob as a parameter is not working.
FROM sysadm.mpulktm1@to_bscsprd_rpt m1 WHERE tmcode IN ( SELECT tmcode FROM sysadm.rateplan@to_bscsprd_rpt WHERE shdes IN ( SELECT REGEXP_SUBSTR (v_tmcode_list ... in the clob).I am executing from sql...
View ArticleBushy Recursion: SQL Techniques
SELECT case when mgr is null then 'null' else 'not' end AS nullility , count(*), sum(count(*))over() cnt FROM ( SELECT empno, mgr , CONNECT_BY_ISLEAF AS "LEAFER" ,...
View Articlesys.dm_exec_sql_text (Transact-SQL)
Obtain information about the top five queries by average CPU time The following example returns the text of the SQL statement and average CPU time for the top five queries. SELECT TOP 5...
View ArticleGetting word count from context text index by joining to indexed rows
Using standard SQL there are various words-to-rows techniques ... insert into t values ('some text more text extra text some more text'); commit; select trim(regexp_substr(t.x, '[[:alpha:]]+', 1,...
View ArticleRagged Hierarchy DBMS RANDOM-ly For Testing
InitCap(SUBSTR(EmployeeName,2,999)) -- AS LastName AS EmployeeName ... Reportsto IS NULL connect by prior employeeID = ReportsTo ) group by depth# order by 1,2 SQL> / DEPTH# INTERIOR LEAF NODE_CNT...
View Article