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…
Tag: sql
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
Return multiple fields as a record in PostgreSQL with PL/pgSQL
I am writing a SP, using PL/pgSQL. I want to return a record, comprised of fields from several different tables. Could look something like this: CREATE OR REPLACE FUNCTION get_object_fields(name text)…
Select count of rows in another table in a Postgres SELECT statement
I don’t know quite how to phrase this so please help me with the title as well. 🙂 I have two tables. Let’s call them A and B. The B table has a a_id foreign key that points at A.id. Now I would like to write a SELECT statement that fetches all A records, with an additional column containing the
How to extract year and month from date in PostgreSQL without using to_char() function?
I want to select sql: SELECT “year-month” from table group by “year-month” AND order by date, where year-month – format for date “1978-01″,”1923-12”. select to_char of couse work, but not “right” order: Answer e.g. http://www.postgresql.org/doc…
MySQL “IN” operator performance on (large?) number of values
I have been experimenting with Redis and MongoDB lately and it would seem that there are often cases where you would store an array of id’s in either MongoDB or Redis. I’ll stick with Redis for this question since I am asking about the MySQL IN operator. I was wondering how performant it is to lis…
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…