Viewing 15 posts - 556 through 570 (of 1,468 total)
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
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
Viewing 15 posts - 556 through 570 (of 1,468 total)