Viewing 15 posts - 571 through 585 (of 1,468 total)
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
So, although my prev code produced the correct results, it was clunky at best.
Here is a cleaned up version of the code
CREATE FUNCTION dbo.MonthStartEnd( @DateInMonth date )
RETURNS...
June 3, 2019 at 12:16 pm
I have modified the proc to do a check and cater for the date that falls into the next month
CREATE FUNCTION dbo.MonthStartEnd2( @DateInMonth date )
RETURNS TABLE WITH...
May 31, 2019 at 10:53 am
For a single value, you can still call the function twice
DECLARE @TheDate AS date = '2019-01-28';
SELECT MonthStart = CASE WHEN @TheDate > mse.MonthEnd THEN mse2.MonthStart ELSE...
May 31, 2019 at 10:25 am
Thanks Des, That Table is just static showing the Start and End Months. It will not be available in Production. Using your function still gives me incorrect dates when...
May 31, 2019 at 10:15 am
Start with a iTVF that will calculate the dates for the month
CREATE FUNCTION dbo.MonthStartEnd( @DateInMonth date )
RETURNS TABLE WITH SCHEMABINDING
AS RETURN
WITH cteBaseValues AS (
...
May 31, 2019 at 9:32 am
So, you now get a number from the Sequence Object
DECLARE @PolicyNumb AS INT
Set @PolicyNumb = NEXT VALUE FOR PolNo
but you do not use it
Insert...
May 31, 2019 at 4:17 am
You could always use a SEQUENCE object to generate an ever increasing number
You would then use NEXT VALUE FOR in order to get the next number.
May 30, 2019 at 1:40 pm
Since you appear to be using SQL 2016, you can also look at the new STRING_SPLIT function
May 30, 2019 at 11:45 am
Based on the sample data, this should get you what you want
WITH cteStarts as (
SELECT StartID = LogID
FROM #Logs
WHERE LogMessage =...
May 18, 2019 at 6:40 am
On a side note, if you have any control over the structure, you would be better off storing the date as a DATE or DATETIME field. Then it can be...
May 15, 2019 at 2:42 pm
Hi, I have found things online about this but nothing is working. I have a field that is a Varchar(20), which holds a Date in it (like this 05/04/2019)....
May 15, 2019 at 2:40 pm
Viewing 15 posts - 571 through 585 (of 1,468 total)