Viewing 15 posts - 5,311 through 5,325 (of 10,144 total)
Can anyone join in?
Here's an efficient dynamic SQL version and a rCTE version. The rCTE version updates a million rows in about 30 seconds, the dynamic SQL version appears to...
January 22, 2013 at 5:37 am
-- To obtain accurate rowcounts from the two tables, you need to aggregate them separately
;WITH Matrix (listcode,[year]) AS (
(SELECT DISTINCT listcode FROM NamesTest) as A
CROSS JOIN
(SELECT DISTINCT [year] FROM NamesTest...
January 22, 2013 at 1:20 am
UPDATE od
SET value_exists = 1
FROM LII od
INNER JOIN VPL sl
ON sl.it LIKE '%' + od.value + '%'
WHERE od.tn = 'VPL'
AND od.cn = 'it'
AND od.opr =...
January 22, 2013 at 12:59 am
Welsh Corgi (1/19/2013)
SELECT
CASE WHEN CAST(LEFT(Customer.STARTDATE, 2 AS VARCHAR(2)))
...
January 21, 2013 at 9:40 am
Have you considered using a more efficient inline table-valued function instead? Here are a couple of ideas:
DECLARE @amount MONEY
SET @amount = -3211987654321.10 -- [-3,210,987,654,321.10]
---------------------------------------------------------------------------------------
SELECT
FormattedAmount = CASE SIGN(@amount) WHEN -1...
January 21, 2013 at 5:13 am
Dehqon D. (1/18/2013)
Thanks for idea @demonfox, you have got it right. But how to change it to fit my ChrisM@Work code.
Like this?
--===== Create the table
CREATE TABLE #T_BMAL(
[DocLinkID] [nvarchar](50)...
January 21, 2013 at 1:51 am
Strip out the noise, and introduce another little statement.
SELECT [An Aggregate] = SUM(1)
FROM (SELECT n = 1) d
WHERE 1=0
SELECT [An Aggregate] = COUNT(*)
FROM (SELECT n = 1) d
WHERE 1=0
SELECT [Something]...
January 18, 2013 at 3:35 am
-- you only need to read the SalesGLLink table once:
INSERT INTO #TempSalesGLLink(
StoreId, LocId, SalesGLLinkUniqueNum, SalesTypeCd, LineCd,
VehSaleAcct, VehSaleDept, TradeACVAcct, TradeACVDept, OverAllowAcct, OverAllowDept, LoanDiscountAcct, LoanDiscountDept,
DueFromFinAcct, DueFromFinDept, CashDownAcct, CashDownDept, CostGoodsAcct, CostGoodsDept, InvSoldDept,...
January 17, 2013 at 8:27 am
HildaJ (1/17/2013)
January 17, 2013 at 8:17 am
bli-963763 (1/17/2013)
I would never write a so complicated script for this simple functionality. It's too hard to maintain.
I'd very much like to see your simpler version.
January 17, 2013 at 8:04 am
-- Convert to an inline table-valued function: more efficient.
-- minimise the work done to identify a date within a string.
DECLARE @InputString NVARCHAR(500) = 'ABC01/01/2013XYZ'
SELECT
DateString = CASE WHEN ISDATE(PatternString) =...
January 17, 2013 at 7:03 am
It looks ok to me, apart from UNION picking up the 40th bin. When this is done, the query is quite efficient:
;with cteHistogram (N, StartBin, EndBin, TotalCount)
as
(
select
N,
@min-2+(@interval*(N-1)) StartBin,...
January 17, 2013 at 3:42 am
dwain.c (1/16/2013)
... Are you sure you're not part Navaho?
No but one of my programming buddies went AWOL for six months last year - and resurfaced in Michigan married to...
January 17, 2013 at 1:11 am
sabeer.mvit (1/16/2013)
With compTable(cid,ccid,ccount)
as
AS
(
select...
January 17, 2013 at 1:09 am
Sorry, my mistake:
SELECT
y.MonthNo,
y.[Year],
y.[Month],
COUNT(doclinkid) as Registered, -- is this correct?
COUNT(DISTINCT doclinkid) as Registered, -- OR is this correct?
SUM(x.Finalised) as Finalised,
COUNT(*) - SUM(x.Finalised) AS [Remaining]
FROM REPWPK.T_BMAL
CROSS APPLY...
January 16, 2013 at 9:36 am
Viewing 15 posts - 5,311 through 5,325 (of 10,144 total)