Viewing 15 posts - 721 through 735 (of 7,597 total)
Best practice is to use a tally table in preference to a loop, so I added that to the code. No test data provided so I couldn't test the code.
July 14, 2022 at 4:44 am
Afaik this actually produces the desired output. Should work with SQL 2014. It uses the ordinal splitter DelimitedSplit8K_Lead. The query: splits the input string on '_' underscore, finds the...
July 14, 2022 at 4:28 am
You could try this script: https://www.sqlservercentral.com/scripts/get-file-sizes-of-database-files-and-free-space-on-disk
If you've got the time to wait for it to run 🙂
It really makes no sense to send every db file thru the...
July 13, 2022 at 7:57 pm
Here's a stand-alone version of the proc I created for work. Naturally adjust is as needed to match your requirements. The proc goes into the master db (and is marked...
July 13, 2022 at 7:25 pm
I thought later of one possible correction to removing the file extension, just in case two or more periods (.) appear in the value.
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER...
July 13, 2022 at 5:42 pm
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO
CREATE FUNCTION [dbo].[fn_GetAlphabetsAndUnderscoresOnly]
(
@string VARCHAR(8000)
)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @invalidCharLocation SMALLINT
SET @string = LEFT(@string, CHARINDEX('.', @string + '.') - 1)
SET @invalidCharLocation = PATINDEX('%[^A-Za-z_]%',...
July 12, 2022 at 11:18 pm
The missing index suggestions are not connected to specific queries in versions prior to SQL Server 2019. SQL Server 2019 added the sys.dm_db_missing_index_group_stats_query DMV. This DMV tells...
July 12, 2022 at 7:52 pm
The missing index suggestions are not connected to specific queries in versions prior to SQL Server 2019. SQL Server 2019 added the sys.dm_db_missing_index_group_stats_query DMV. This DMV tells you which...
July 12, 2022 at 7:07 pm
Sorry for the confusion. Yes, as the data stands right now the entire column should be populated with an *. If the department column included 0001 and 0002, then...
July 11, 2022 at 1:10 pm
I'm not really sure what you're trying to do, but it sounds like something like this:
UPDATE tn
SET tn.[Export Deparment] = CASE WHEN Distinct_Department_Count = 1 THEN '*'...
July 8, 2022 at 9:21 pm
Also, since the table you are INSERTing to already exists, you need to INSERT to it, not SELECT ... INTO it:
Truncate TABLE Planning
Insert Into Planning
Select *
from (select...
July 8, 2022 at 4:56 pm
(2) Here's my answer:
CREATE TABLE dbo.emp_training ( id int IDENTITY(1, 1) NOT NULL, emp_id int NOT NULL, training_id int NOT NULL, status char(1) NULL CHECK(status IN ('F',...
July 8, 2022 at 3:00 pm
Here's an alternative:
SELECT E.*, LEFT(ds.Item, CHARINDEX(')', ds.Item + ')') - 1) AS Invoice
FROM @ErrList E
CROSS APPLY (SELECT Item FROM dbo.DelimitedSplit8K(ErrDesc, '(') WHERE ItemNumber = 3) AS ds
July 7, 2022 at 2:37 pm
On the missing index views? They just don't say anything. I'm not talking about all the other DMVs. They're vital. 1 million percent so. But the missing...
July 6, 2022 at 10:03 pm
Viewing 15 posts - 721 through 735 (of 7,597 total)