query

Why doesn't SQL Full Text Indexing return results for words containing #?

For instance, my query is like the following using SQL Server 2005: SELECT * FROM Table WHERE FREETEXT(SearchField, 'c#') I have a full text index defined to use the column SearchField which returns results when using: SELECT * FROM Table WHERE SearchField LIKE '%c#%' I believe # is a special letter, so how do I allow FREETEXT to w...

Multiple Updates in MySQL

I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL? Edit: For example I have the following Name   id  Col1  Col2Row1   1    6     1Row2   2    2     3Row3   3    9     5Row4   4    16    8 I want to combine all the following Updates into one query UPDATE tab...

How do I Concatenate entire result sets in MySQL?

I'm trying out the following query: SELECT A,B,C FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C FROM table WHERE field LIKE '%query' UNION SELECT A,B,C FROM table WHERE field LIKE '%query%' GROUP BY B ORDER BY B ASC LIMIT 5 That's three queries stuck together, kindasorta. However, the result set that comes back reflects resul...

SQL, Auxiliary table of numbers

For certain types of sql queries, an auxiliary table of numbers can be very useful. It may be created as a table with as many rows as you need for a particular task or as a user defined function that returns the number of rows required in each query. What is the optimal way to create such a function? ...

SQL query to compare product sales by month

I have a Monthly Status database view I need to build a report based on. The data in the view looks something like this: Category | Revenue | Yearh | Month Bikes 10 000 2008 1 Bikes 12 000 2008 2 Bikes 12 000 2008 3 Bikes 15 000 2008 1 Bikes 11 000 2007 ...

SQL/Query tools?

I haven't really done a ton of database work in a few years and have become unaccustomed with the tools available. Back a few years ago I was working with oracle databases and was using primarily TOAD with a little bit of MS Access as my tools of choice to prototype the queries I was using in my applications. I really loved TOAD in tha...

is it better to structure an SQL table to have a match, or return no result

I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers. I'm using a simple All...

Why are relational set-based queries better than cursors?

When writing database queries in something like TSQL or PLSQL, we often have a choice of iterating over rows with a cursor to accomplish the task, or crafting a single SQL statement that does the same job all at once. Also, we have the choice of simply pulling a large set of data back into our application and then processing it row by r...

use table metadata for select statement in SQL Server?

I have a large database and would like to select table names that have a certain column name. I have done something like this in MySQL, but can't find any info on SQL Server. I want to do something like: select [table] from [db] where table [has column 'classtypeid'] how can I do something like this? ...

Mysql: Using "AND" Operation on tags and categories tables in Wordpress

This is a very specific question regarding mysql as implemented in WordPress. I'm trying to develop a plugin which will show (select) posts that have specific 'tags' and belong to specific 'categories' (both multiple) I was told it's impossible because the way categories and tags are stored: wp_posts contains a lists of post, each po...

Table Scan vs. Add Index - which is quicker?

I have a table with many millions of rows. I need to find all the rows with a specific column value. That column is not in an index, so a table scan results. But would it be quicker to add an index with the column at the head (prime key following), do the query, then drop the index? I can't add an index permanently as the user is nomin...

Do indexes work with "IN" clause

If I have a query like: Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3) and I have an index on the EmployeeTypeId field, does SQL server still use that index? ...

C# - SQLClient - Simplest INSERT

Before someone gets in a tizzy because this was answered elsewhere (not sure if it was,but...), the 5 "related questions" shown right now do not match what I'm looking for, and I searched the string "sql insert" and did not find quite what I was looking for. So I'm basically trying to figure out the simplest way to perform your basic in...

SQL: Select like column from two tables

I have a database with two tables (Table1 and Table2). They both have a common column [ColumnA] which is an nvarchar. How can I select this column from both tables and return it as a single column in my result set? So I'm looking for something like: ColumnA in Table1: a b c ColumnA in Table2: d e f Result set should be: a b c d e f ...

How can I monitor the executed sql statements on a ms SQL server 2005

In a project of mine the SQL statements that are executed against a ms SQL server are failing for some unknown reason. Some of the code is already used in production so debugging it is not an easy task. Therefore I need a way to see in the database itself what SQL statements are used, as the statements are generated at runtime by the pro...

SQL Query to get latest price

I have a table containing prices for a lot of different "things" in a MS SQL 2005 table. There are hundreds of records per thing per day and the different things gets price updates at different times. ID uniqueidentifier not null, ThingID int NOT NULL, PriceDateTime datetime NOT NULL, Price decimal(18,4) NOT NULL I need to get today's...

What table/view do you query against to select all the table names in a schema in Oracle?

What object do you query against to select all the table names in a schema in Oracle? ...

How to force nolock hint for sql server logins

Does anyone know of a way to force a nolock hint on all transactions issued by a certain user? I'd like to provide a login for a support team to query the production system, but I want to protect it by forcing a nolock on everything they do. I'm using SQL Server 2005. ...

Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc.

I've heard that SELECT * is generally bad practice to use when writing SQL commands because it is more efficient to SELECT columns you specifically need. If I need to SELECT every column in a table, should I use SELECT * or SELECT column1, colum2, column3, etc. Does the efficiency really matter in this case? I'd think SELECT * would be...

SharePoint Content Query Web Part

Hi, I have a content query web part that queries by content type against a site collection. I have grouped it by content type so I have: -- Agenda (Content Type) ----Agenda #1 ----Agenda #2 -- Report (Content Type) ----Report #1 ----Report #2 I would like to show a second grouping for site, so: -- Agenda (Content Type) ----This Site...