Viewing 15 posts - 1 through 15 (of 7,608 total)
You can also do it with a single result set. Which performs better would depend, so you'd have to test that out.
This method would also be much easier if you...
December 10, 2025 at 9:10 pm
Great, glad it helped. Many thanks for the feedback.
December 10, 2025 at 9:04 pm
I'm not sure PIVOT can give you the results you want.
Maybe try this instead?:
SELECT
COALESCE(BBBB.STOCK_CODE, CCCC.STOCK_CODE) AS STOCK_CODE,
COALESCE(BBBB.MNEMONIC, CCCC.MNEMONIC)...
December 10, 2025 at 7:58 pm
D'OH, obviously there is an mbi column, since it's directly referenced in the query.
The point here is that, in a subquery, if you reference a column that exists in a...
December 9, 2025 at 4:15 pm
Is there an MBI column in table "edi.dbo.PEC_RGT_EDI_834_Inbound_Exception"?
If so, the second query works because it is comparing xx.MBI to itself, which will always be equal (unless MBI is NULL, oc).
x.MBI...
December 9, 2025 at 2:44 pm
My thoughts on this:
(1) Decide whether you want to include nvarchar or not.
(2) Gen a list of the tables to be changed: then, if you need to, you can custom...
December 1, 2025 at 8:57 pm
I identified the changes I made to the original code using /*--<<--*/ on/around them. This code should also perform better.
SELECT
sa.partid AS ALLOC_Part,
sa.quantity,
sa.ordertype,
sa.worksorderid,
sa.reference,
sa.stockvalue,
apm.partdesc,
soi.orderid,
soi.itemnumber,
soi.partid AS SOI_Part,
so.traderid,
t.name,
u.name As SalesRep,
sub.Max_Batchvalue AS...
November 24, 2025 at 4:55 pm
You could also use Brian Gale's approach and use a proc to generate all the code for you. Personally I would stick with dynamic SQL, but the other is an...
November 17, 2025 at 9:38 pm
Columnstore won't gain you much (other than perhaps some disk space) since you are reading all the columns. Personally, I would just use page compression.
November 12, 2025 at 9:58 pm
Absolutely agree with analyzing page compression for the table. It could be a huge help. You can use:
EXEC sys.sp_estimate_data_compression_savings 'dbo', 'table_name', NULL, NULL, 'PAGE'
As you noted, the nonclus index is...
November 12, 2025 at 6:31 pm
I thought it was more complicated than that because a CHAR(13) should also count as a "space" as far as splitting words?! Perhaps not, I guess it depends on exactly...
November 6, 2025 at 7:38 pm
IF UPDATE(CreditLimit)
That approach seems preferable to me, unless you really have to use COLUMNS_UPDATED()
August 13, 2025 at 2:07 pm
If the quirky UPDATE works, can you modify the original table to include the new calculated column?
Let me ask: once a value has been calc'd, would it ever change? In...
May 12, 2025 at 6:12 pm
Please provide data in usable format: CREATE TABLE and INSERT statment(s). That is way more useful to us than a "picture" of data.
May 9, 2025 at 6:35 pm
Would need to see row counts to better understand the query.
How is the Departments table clustered? In general, again without knowing any details at this point, DepartmentID first followed by...
April 30, 2025 at 6:09 pm
Viewing 15 posts - 1 through 15 (of 7,608 total)