Viewing 15 posts - 451 through 465 (of 3,500 total)
Since a MERGE is basically an INSERT/UPDATE, and you have 3 possible caes, you might want to just skip the MERGE and use separate INSERT/UPDATE statements.
IF (TestInvalid)
BEGIN
INSERT INTO FailTable()....
END
ELSE
IF EXISTS().... ...
December 17, 2021 at 5:18 am
If it's not working when it's crazy complex, why not simplify and built it a piece at a time?
The error message is pretty clear. Any time you create a totals/aggregate...
December 17, 2021 at 2:21 am
IF <test>
BEGIN
SELECT... FROM...WHERE... <params>
END
ELSE
SELECT...FROM WHERE <different params>
There's nothing stopping you from forking the two queries with an IF statement.
December 15, 2021 at 3:43 pm
What do you mean "second temp table"? You can define multiple CTEs inside your expression, and then just use them both/all in the final one.
WITH cte1 (col1, col2, col3)
AS (SELECT...),
cte2(colA,...
December 14, 2021 at 3:56 am
COALESCE(column,0) ?
December 14, 2021 at 12:38 am
Totally missed it... sounds like the classic Islands problem. (Clump all contiguous spans together).
SQL Server Window Functions Gaps and Islands Problem (mssqltips.com)
December 10, 2021 at 1:30 am
If you need to look at previous or next records in a set, use LAG() or LEAD() with an OVER clause. then you can use conditional logic to see if...
December 9, 2021 at 7:29 pm
Without the CREATE TABLE and INSERT scripts, all we can do is guess. Could you post them?
December 9, 2021 at 2:13 am
so you're looking for a date where there are no scheduling conflicts? (the span of the meeting doesn't overlap/conflict with any meetings of any of the invited participants)?
Sorry, it's just...
December 6, 2021 at 11:47 pm
The dead giveaway that you're new to SQL is that you said these were complex.
What did you try? Post the SQL. People will help you if you do that. If...
December 6, 2021 at 3:01 am
Hate to break it to you, but the way you get better at SQL is the same way you get better at anything else. By trying, maybe failing, and learning...
December 3, 2021 at 6:46 am
So what part of DATEADD didn't work for you?
If you're adding values from the previous record, you need to look at the windowing function LAG().
And if you need to do...
December 3, 2021 at 6:12 am
Are you just adding [Duration] minutes to [CodeStartTime]? If so, then use DATEADD
select dateadd(minute,12,'6/1/2020 11:15')
December 3, 2021 at 2:14 am
I don't there is a reliable way of doing this in SSRS or T-SQL. It's just that some names have spaces in them etc. They're not standard, so a pure...
December 2, 2021 at 3:45 am
"It takes too much time" -- Got any indexes on the tables? like on the Primary/Foreign Keys that you're doing your joins on? Did you look at the query's execution...
November 30, 2021 at 6:41 am
Viewing 15 posts - 451 through 465 (of 3,500 total)