Skip to content

Tag: sql

SQL Comments on Create Table on SQL Server 2008

I need to create some pretty big tables in SQL Server 2008, while I do have SQL Server Management Studio, I would like to comment the tables and the columns when I create the table. How do I do this? Example of the query I am running: I’ve tried COMMENT’Expiration Date for the Adult CPR’ and…

SQL UPDATE Command

Question. I’m trying to use SQL to update a listview in C#. Using the Query Builder I can do a select, update, insert and delete. Ive got my select but I’m trying to get my update to work with no luck.( I want to use the update button on the listview to update the record) I need some insight as

Select Nth Row From A Table In Oracle

How can I select the Nth row from a table in Oracle? I tried but that didn’t work. Please help! Answer Based on the classic answer: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:127412348064

Detect overlapping date ranges from the same table

I have a table with the following data And want to get the following results Any ideas on where to start? A lot of the reading I’ve done suggests I need to create entries and for each day and join on matching days, is this the only way? Answer If you already have entries for each day that should work,

MS SQL query to list count by status

I want to achieved the result below. I want to list all records having a status of “For Approval” together with this condition: For example for Username ‘Leo’ Then sum all the status having “For Approval” which is the checker is ‘Leo’ with the condition above An…

T-SQL Conditional WHERE Clause

Found a couple of similar questions here on this, but couldn’t figure out how to apply to my scenario. My function has a parameter called @IncludeBelow. Values are 0 or 1 (BIT). I have this query: If @IncludeBelow is 0, i need the query to be this: If @IncludeBelow is 1, that last line needs to be exclu…