Viewing 15 posts - 2,401 through 2,415 (of 7,608 total)
The full, unlimited Cartesian join will be huge overhead. At least turn the match of the tables into a standard join:
select a.Ref_Tran_OU'Tran_OU', a.Ref_Tran_Type'Tran_Type', a.Ref_Tran_No'Tran_No', 'N', b.Remarks
from SampleTable...
April 29, 2020 at 1:59 pm
D'OH, quite right, a copy/paste mishap I think. I have corrected the original code.
April 27, 2020 at 5:08 pm
Thanks for the queries above. For the PL update, it's not working as expected .
OK, adjust it as you need to. You didn't provide enough details to know which...
April 24, 2020 at 7:47 pm
I completely agree with Celko.
At my place of work we had to import some employee data that came from 2 completely separate systems, one for temporary and one for...
April 24, 2020 at 7:46 pm
Edit: Corrected typo, as pointed out by Mr. Brian Gale.
UPDATE D
SET MarketCompleted = 0, MarketAssigned = 0
FROM (
SELECT *, ROW_NUMBER() OVER(PARTITION BY ID,...
April 24, 2020 at 7:31 pm
UPDATE dbo.table_name
SET data_column = REPLACE(data_column, '*', ISNULL(REPLICATE('0', 12 - (LEN(data_column) - 1)), ''))
WHERE (LEN(data_column_name) < 12 OR LEN(data_column_name) = 13) AND
(data_column LIKE '%*%')
April 22, 2020 at 4:57 pm
REPLACE(data_column, '*', ISNULL(REPLICATE('0', 12 - (LEN(data_column) - 1)), ''))
Some examples:
SELECT data_column,
REPLACE(data_column, '*', ISNULL(REPLICATE('0', 12 - (LEN(data_column) - 1)), '')) AS new_data
FROM ( VALUES('ABC*1234'),('BC*234'),('CDEFG*1'),('D*23456789012')...
April 22, 2020 at 3:11 pm
Assuming the PKs are the clustering keys [*], for best performance you'd need to change the order of the keys in the Data table.
If you always (with perhaps only extremely...
April 21, 2020 at 9:55 pm
Create a proc in the master db, with a name beginning with sp_, and you can directly run it against any user db. [If you're in Azure, nevermind, this won't...
April 21, 2020 at 9:22 pm
We need the full DDL for all tables involved, including indexes, but for now:
1 How is the dmhdb.dbo.Data clustered?
2 The syntax on your update is not best practice and you...
April 21, 2020 at 9:15 pm
1 The nonclus indexes should be unique, not non-unique. Worst case, add an identity to the table and use that to make unique non-clus keys.
2 Are the nonclus indexes page...
April 21, 2020 at 9:09 pm
Create two base source tables: one with only current_record = 'Y' rows, and one with only current_record <> 'Y' rows. Create a SQL constraint on the each table that enforces...
April 21, 2020 at 9:00 pm
1.2M rows * 10KB bytes per row is a huge amount of data, ~12GB. I can imagine it could take 6 mins to transfer that much data.
It would be very...
April 20, 2020 at 6:27 pm
As I noted above, views sys.foreign_keys and sys.foreign_key_columns should give you FK details. I can't imagine how your SQL doesn't have those views, since they've been around a long time.
April 1, 2020 at 6:38 pm
Agreed.
Views sys.foreign_keys and sys.foreign_key_columns should give you FK details.
Also look at sys.dm_sql_referenced_entities and sys.dm_sql_referencing_entities.
For just any reference to another object, not for a defined relationship, try sys.sql_expression_dependencies. For example, if...
April 1, 2020 at 6:13 pm
Viewing 15 posts - 2,401 through 2,415 (of 7,608 total)