Viewing 15 posts - 1 through 15 (of 166 total)
The "CASE" statements above look correct, but that method will always add the commas even if there is no displayed value. You may get a final string that looks like...
June 30, 2020 at 5:08 pm
Rather then convert to numbers, transform, and convert back, you could just select the portion of the string you want.
SELECTMyColumn,
NewColumn= SUBSTRING(MyColumn, 1, CHARINDEX('.', MyColumn) + 1)
/*...
February 27, 2020 at 3:47 pm
Thank you for providing the table definitions, data, and code to produce the results. However, executing the code gives the following error: Invalid object name 'EmployeeMemberMaster'. That table needs to...
February 27, 2020 at 3:24 pm
This looks like a great place to use the EXCEPT statement. EXCEPT is basically the opposite of UNION; UNION joins two sets of data, while EXCEPT subtracts one set from...
January 22, 2020 at 3:07 pm
I believe it has to do with collation, based on his article: https://dba.stackexchange.com/questions/208414/why-isnt-unicode-character-replaced-in-some-cases.
SELECTSampleWord,
[No_Collate]= CAST(REPLACE(REPLACE(SampleWord, NCHAR(0x0D), ''), NCHAR(0x0A), '') AS NVARCHAR(50)),
[With_Collate]= CAST(REPLACE(REPLACE(SampleWord COLLATE Latin1_General_100_BIN2, NCHAR(0x0D), ''),...
January 21, 2020 at 9:56 pm
Jeff: Thanks for pointing out dbgaragedays's post; I skipped right over it.
September 6, 2019 at 10:26 pm
Rather than check the table, I check the main index on the table to see how many rows it has. In my experience, this is much faster than checking the...
September 5, 2019 at 12:21 am
This gives a running total, ordered by the foo_id. You can now take this running total and put it in a view that shows (running_item_tot % 6). I'll let...
August 30, 2019 at 8:49 pm
I usually solve the problem by doing a JOIN first to get the set of records with a "SortSeq" column that calculates "1" for my preferred row, the JOIN that...
August 29, 2019 at 2:49 am
I find it humorous that, for someone who argued so strongly against Hungarian notation on another thread, this object names starts with "fn". 🙂
Question: rather than have one function that...
August 14, 2019 at 4:15 pm
Typing in all that data individually could be cumbersome. There are system stored procedures to help with maintenance, such as sp_AddExtendedProperty. Using these procedures, we can integrate the maintenance...
August 9, 2019 at 1:36 pm
Building on DesNorton's statement, you may want to show all the dates in the range, even if those dates have no sales. To do that, you need to build a...
August 1, 2019 at 5:04 pm
Thank for providing a scenario. To follow on, a procedure that lives on DatabaseA and references DatabaseA and DatabaseB, which are restored as DatabaseA_20190702 and DatabaseB_20190702, would have a similar...
July 2, 2019 at 5:04 pm
If this is within a stored proc in the database, please consider removing the EtiquetasKLC. prefix from the table names. This is a bad practice, unless you are executing...
July 2, 2019 at 3:36 pm
Here is another option to add to your list.
WITHBaseData
AS(
SELECTmemid,
memtype,
mdate,
ROW_NUMBER() OVER (PARTITION BY memid ORDER BY mdate) AS RowAsc,
ROW_NUMBER() OVER (PARTITION BY memid ORDER BY mdate DESC) AS...
July 2, 2019 at 3:22 pm
Viewing 15 posts - 1 through 15 (of 166 total)