Viewing 15 posts - 406 through 420 (of 4,087 total)
You do realize that the IF
and the ELSE
section are EXACTLY THE SAME, right? One definition of insanity is doing the same thing and expecting different results.
Drew
September 19, 2019 at 7:03 pm
Can't you use RIGHT or SUBSTRING ?
You can use RIGHT()
or SUBSTRING()
, but both of those tend to be more complex than STUFF()
.
Drew
September 19, 2019 at 6:52 pm
Hi,
I am doing STUFF in my query which is concatenating the blank data too and data looks like below. Sometimes there is space+comma and sometimes only comma in the...
September 19, 2019 at 6:50 pm
You would use a CROSS APPLY
or OUTER APPLY
like any other table-valued function.
FROM data.dbo.CalendarEvents AS ce
INNER JOIN data.dbo.ObjectMetadata AS OM2
ON ce.ParentObject = OM2.ObjectID
INNER...
September 19, 2019 at 4:20 pm
Maybe Drew will chime in. He comes up with some great creative SQL solutions.
I would need some data and expected results to work with.
Drew
September 19, 2019 at 3:39 pm
Also, get rid of the DISTINCT
. UNION
already does a distinct, so specifying DISTINCT
here just clutters up your code with no benefit.
Drew
September 19, 2019 at 2:32 pm
Hey Drew,
Which part of the query is static, I am curious?
If you referring to the last query I posted, that's the printed version after I did PRINT @query.
I don't...
September 18, 2019 at 8:43 pm
The problem you are seeing is that you made a dynamic part of your query static. Specifically, the 'Year_' + CONVERT(NCHAR(4), YEAR(eventyear))
needs to be dynamic so that when you...
September 18, 2019 at 7:55 pm
tjolliffe's approach requires two scans of each of the tables. The following only uses one scan of each of the tables, but you may be better off just skipping the...
September 18, 2019 at 7:34 pm
It's embedded. You need to ADD quotes, not take them away
''YEAR_'' + CONVERT(nvarchar(8), YEAR(eventyear)) eventyear,
Before you execute the dynamic SQL, print it.
PRINT @query
Run that query, fix the issues, and...
September 18, 2019 at 6:04 pm
DATE/TIME data should be stored in DATE/TIME fields. If they are stored in any other format, you should consider changing that.
DATE/TIME data is not stored in a human-readable format. It...
September 17, 2019 at 6:48 pm
T-SQL 2012 has a new built in function to give a running total, so you don't need a cursor for running totals that sum distinct counts. Previously sum...
September 16, 2019 at 9:55 pm
Did you really think it was necessary to post 5000 lines of data to illustrate your issue?
Drew
September 16, 2019 at 4:15 pm
From your data, I think what you're really dealing with is a overlapping intervals problem. You have overlapping intervals (student start and end dates) and you need a running count...
September 16, 2019 at 4:00 pm
This thread is SEVEN YEARS OLD, so it's not safe to make any assumptions about what the OP is currently using.
Drew
September 16, 2019 at 3:03 pm
Viewing 15 posts - 406 through 420 (of 4,087 total)