Viewing 15 posts - 556 through 570 (of 1,464 total)
You can also use the following, which will take care of teh leap year
DECLARE @Year int = 2019;
SELECT PeriodID, EOMONTH(PeriodID + ' 01 ' + CONVERT(VARCHAR(4), @Year))...
June 13, 2019 at 1:27 am
Having a loop is an immediate red flag. Are you sure you can't do it without a loop?
That said, if you can't avoid the loop, you can implement a retry...
June 10, 2019 at 12:37 pm
If I understand the requirements, a simple UPDATE statement should do the trick.
This will increment every record by 5.
UPDATE YourTable
SET UniqueField = UniqueField + 5;
Although not recommended,...
June 9, 2019 at 8:01 pm
This should also work
WITH cteSampleData AS (
SELECT v.SampleString
FROM ( VALUES ('P11034'), ('P1103'), ('P110345') ) v(SampleString)
)
SELECT SampleString
,...
June 6, 2019 at 8:51 pm
Hi, I am in a scenario where I need to manipulate some text. For example:
June 6, 2019 at 8:43 pm
Let's work backwards on this.
To view records that you are trying to filter out
SELECT *
FROM ##FctLossData
WHERE ClaimNumber LIKE '836%'
However, ClaimNumber is made up of 2 fields
June 6, 2019 at 7:50 pm
retired
Reinstated
June 6, 2019 at 10:20 am
Please don't double post.
Further responses are available on https://www.sqlservercentral.com/forums/topic/count-of-entries-grouped-by-month-extracted-from-a-date
June 6, 2019 at 10:16 am
You need to add a GROUP BY
SELECT DATENAME(MONTH, CAST(RecvdDate AS Date)) + ' ' + CONVERT(varchar(10), YEAR(CAST(RecvdDate AS Date))) AS 'MonthName'
...
June 6, 2019 at 6:02 am
Your function is a scalar function, which has terrible performance.
Below is an iTvf (inline table valued function) that will get the last business day
CREATE FUNCTION [dbo].[F_PreviousBusinessDay]
(
@DateInput DATE
)
/*...
June 5, 2019 at 3:39 am
If you are unable to change the structure of your DB, you could use a splitter function. In SQL 2016, you have a built-in splitter function which I believe...
June 4, 2019 at 8:08 pm
If you are unable to change the structure of your DB, you could use a splitter function. In SQL 2016, you have a built-in splitter function which I believe should...
June 4, 2019 at 7:56 pm
I have a situation whereas I need to include a column that is nonexistent in the table(s). The primary table has a CreatedDate and an UpdatedDate field. I need...
June 3, 2019 at 3:00 pm
How nice it is to see this again - a bunch of folks working the hell out of a problem to come up with their solutions, each one faster...
June 3, 2019 at 1:22 pm
Object names cannot be passed into sp_execute_sql.
On another note, there is no need to use nvarchar(max) for your object types.
@table ...
June 3, 2019 at 12:56 pm
Viewing 15 posts - 556 through 570 (of 1,464 total)