Viewing 15 posts - 541 through 555 (of 1,464 total)
Use this pattern to pad your values
DECLARE @PaddingChar char(1) = 'x'; -- Change your padding character here
DECLARE @RequiredLen int = 7; -- Change the padded length here
SELECT...
July 1, 2019 at 6:09 am
You can add padding to the start/end of the value, then use left/right to get the required length
DECLARE @AccountNumber2 varchar(20) = '8063#018375';
DECLARE @PaddingChar char(1) = 'x'; --...
June 28, 2019 at 10:41 am
In the absence of better code, this is what I came up with. I'm assuming you have a table of holidays like #Holidays table. Then you just check for...
June 28, 2019 at 5:37 am
Do you guys run EVERYTHING that goes into production through QA/UAT, or do you trust some users if they have a proven track record of high scores, and only...
June 27, 2019 at 4:21 am
At a guess, this *MIGHT* have improved performance.
WITH cteData AS (
SELECT p.party_id, p.consolidation_ind
FROM ...
June 24, 2019 at 3:25 pm
Thanks for your help. I want to show only the columns City and Company Name. I dont want to show column City with a count of the Cities per...
June 24, 2019 at 1:23 pm
Thank you, Desnorton. We run in Azure SQL on a low end service tier so we don't use temp tables much. I will look into the other possibility.
The temp...
June 22, 2019 at 4:38 am
With a small structure change
ALTER TABLE #TItems ADD
AutoReorder bit
, isFavorite bit
, IsControlled bit;
UPDATE i
SET AutoReorder = a.AutoReorder
, isFavorite ...
June 21, 2019 at 11:02 am
Perfect, suits my needs perfectly thanks. Just to expand for anyone reading this in future: Whilst in my example the result of ROW_NUMBER can not be greater than the...
June 14, 2019 at 1:08 pm
This is a classic (Gaps and) Islands problem. The following will not give you sequential group numbers, but it will give you unique group numbers.
GroupNum = SequenceNumber...
June 14, 2019 at 12:12 pm
Hi DesNorton, Thank you so much for this! It's a massive help and works when creating the task temp table. I am not able to get the script working...
June 14, 2019 at 11:48 am
First, we need some sample data
CREATE TABLE #Tasks (
ID int NOT NULL
...
June 14, 2019 at 8:52 am
Hi, I am passing parameter in my store procedure. declare @year datetime= '2019' select * from table where sportyear=@year How can I extract where if i pass in '2019',...
June 14, 2019 at 8:17 am
There is no need for the case statement.
This should do the trick
SELECT CONVERT(VARCHAR(10), DATEADD(DAY, -1, DATEADD(MONTH, 1, 'February' + ' 01 ' + CONVERT(VARCHAR(4), YEAR(GETDATE())))), 101) AS...
June 13, 2019 at 5:37 pm
You can also use the following, which will take care of teh leap year
DECLARE @Year int = 2019;
SELECT PeriodID, EOMONTH(PeriodID + ' 01 ' +...
June 13, 2019 at 4:29 am
Viewing 15 posts - 541 through 555 (of 1,464 total)