Skip to content

Tag: sql-server

T-SQL Dollar Sign In Expressions

In this answer, there is a trick which allows to use the ROW_NUMBER() windowed function with a ‘constant’ in the ORDER BY clause: After some search in Google, I can’t find what dollar sign means in this context? I’ve tried to execute a simple query: And it returns 0. Could somebody exp…

How to summarize a query separating with commas

I have a list of dates with folios, one folio can have multiple dates. The folio is the employee holiday request folio. (SQL Server 2008) Instead of showing that info like a list I need to show it in the following format: Here is the SQL Fiddle: http://sqlfiddle.com/#!3/0ddd2/7 Answer Larry’s answer is …

Unioning overlapping time ranges, then summing the total time

I have a hardware group and many devices into this group. Example: All devices are monitored using ping. When some device is not working the program add a row into a table saying the start of break. When the device back on then the program update this row saying the end of break. It’s ok to know the tot…

Catch SQL RaiseError in jsp

I am developing a database and some JSP Pages to perform CRUD operations on it. I cannot catch exceptions related to my SQL Code in my JSP Code. For Example: I have this part of code where I raise an error in T-SQL: I need to call the function where I raise those errors in JSP code. Heres a part

Can’t retrieve data from SqlDataReader in C#

I need to insert values into several tables first I have to retrieve university id from table college and then insert faculty name into table faculty and get generated by SQL Server ID. After all of this I have to insert both ids into an other table. Problem is that I have to close readers and after I do it