Skip to content

Tag: sql-server

Filter a case in a where clause

I want to filter on a case statement in my where clause for example: Select name, address, case when code in (50000-8113, 512388-8114) then ‘M345’ else ‘N/A’ end as Mucode Where mucode = ‘…

Arabic text in sp_sqlexec insert return question mark

Records are imported into table #FileRecords and ##TableInsert are dynamic tables, it can be table A, table B(which justify the reason of using exec sp_sqlexec). When Arabic wording going through sp_sqlexec, it will insert ??? instead of the Arabic wording. Is there anything I am not aware of, beside of encod…

Use multiple but identical aggregate function

I’m trying to use two identical aggregate function is SQL Server, where I use COUNT(A) with some condition and COUNT(A) with another condition. For example I want to count all students enrolled in the course ABC, and the second count I want to count all students who have grade A and have enrolled in the…

Returning Records by Week

I’m trying to come up with a way to return a result set from the below data without a loop that shows the number of records by Team for a particular date range by week. I’ve got a Date table (https://www.mssqltips.com/sqlservertip/4054/creating-a-date-dimension-or-calendar-table-in-sql-server/) th…

Get all dates of a Year based on Day Name [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I want to take all Dates of an year based on Day Name. For example If I pas…