sql

mysql: take all records with meeting_id = x and it's parent is available but don't care if available itself ?

how do i select all records matching following criteria: take all records with meeting_id = x AND it's parent is available OR doesn't have parent but don't care if available itself ? table people: id, name, address, meeting_id, available, parent_id ...

Cannot modify table ( using microsoft sql server management studio 2008 )

I create 2 tables and another 1 with foreign keys to the other two. I realized I want to make some changes to table no 3. I try to update a field but I get an error "Saving changes is not permitted. The changes you have made require the following table to be dropped and re-created." I delete those 2 relationships but when I look at d...

Multiple queries in stored procedure

Possible Duplicate: SQL CASE statement Hi Frdz, i have created a stored proc and i put three queries in stored proc with inputvariable @EtlLoadId = 0 and i get three different windows for each query under result tab. is there any chance i can get results from the stored proc (results of three queries) as only one window and r...

can I combine these 2 simple queries into one query?

select count(distinct id) from svn where name='ant' and type='Bug' and select count(distinct id) from svn where name='ant' and type='Feature' Is it possible to combine them into a single query that might reduce the execution time compared to running them individually? Thanks for answering. ...

SQL Server Case when syntax

Ive a big select case in SQL query. (select case tb_usuario.int_id_cargo when 13 then '20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53' when 20 then '' when 21 the...

Performing String parsing with TEXT DataType

Using TEXT datatype in SQL Working on SQL 2000, I would like to perform the following Select @String = SUBSTRING(@String, @idx + DATALENGTH(@firstDelimiter)/ 2,LEN(@String)) NOTE: @String is a type TEXT , @FirstDelimiter is of type Varchar(4). Why am I unable to run the above code? How do I perform the above instead? Is the a...

Adding a reference data to the table column from different table line

I have an event table with following columns: sequence (int) DeviceID (varchar(8)) time_start (datetime) DeviceState (smallint) time_end (datetime) All columns except time_end are populated with the data (my current time_end column is NULL through out the table). What I'd need to do is to populate the time_end column with the event c...

Inserting embed code in database PHP issue

hey, I'm trying to insert an embed code in my database, and it's giving me this error Error adding new data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'movie.php?id=6001', type = 'stream', embed = '<object width=\"500\" ...

MYSQL enumeration: @rownum, odd and even records

Hi, I asked a question about creating temporary/ virtual ids for query results, http://stackoverflow.com/questions/4063998/mysql-php-temporary-virtual-ids-for-query-results/4064066#4064066 I nearly got I wanted with this link, http://craftycodeblog.com/2010/09/13/rownum-simulation-with-mysql/ I have managed to enumerate each row, SEL...

Choosing optimal indexes for a SQL Server table

I have a SQL Server table with the following structure: CREATE TABLE [dbo].[Log]( [LogID] [bigint] IDENTITY(1,1) NOT NULL, [A] [int] NOT NULL, [B] [int] NOT NULL, [C] [int] NOT NULL, [D] [int] NOT NULL, [E] [int] NOT NULL, [Flag1] [bit] NOT NULL, [Flag2] [bit] NOT NULL, [Flag3] [bit] NOT NULL, [Counter] [int] NOT NULL, [Start...

SQL create table and query from it

Morning all, I'm running SQL Server and there are a whole lot of tables in there. I have taken one column from one of these tables using SELECT, and it gives me the list of IDs. I need to use these IDs as the lookup point to get the data for that ID from another table. Is it necessary that I do a CREATE TABE manouvre? I was hoping I c...

weird gridview problem in asp.net

Hello everyone - I have this weird gridview problem in .net, I haven't found what can be the issue so far. Here is what is it about: I have a stored procedure which is consumed by sqldatareader. Then I do have reader read all the values and display from the stored procedure. Problem is happening now. When I am entering some specific va...

Find missing rows using SQL

I have an SQL table as such name | engins| frank ---------------------------+-------+------ John Smith | 8422| 854 (1 rows) And need to make a query such that only return the row john smith when engins is more than 2000 ...

Track changes to SQL query in real time

Hello! Here is my situation: 1) User A must monitor the results of an sql query Q. 2) User B can modify data that may change the results of Q 3) running Q on the entire database is slow What I would like have is: whenever user B modifies the data: with a create, update or delete, then generate the delta to the results of Q. i.e. retur...

Nested Linq performance

We have 2 tables (tblSerials and tblRequests). The question is how can we make this code to execute faster? As you can see "from request in ctx.tblRequests" parts are very similar. Any other better solution? var list = from s in ctx.tblSerials orderby s.CreateDate descending select new { SerialGUID = s.S...

SQL server simple query

How to select value from a table if it value is not null,and select a default value if not?.I.E: select coalesce(username,'its null') from tb_user where int_id_user = 0 I try to run this query but its not working,i expect to get 'its null' since int_id_user is 0,but it returns NULL. ...

Modify a Table field by adding to it.

I have Table1, where I want to modify previous_sum where previous_sum is the sum of the numbers field in Table 2 up to that specific date. Example: Table1 Date___|___previous_sum 01/01__|___20 01/02__|___50 01/03__|___100 Table2 Date___|___numbers 01/01__|___20 01/02__|___30 01/03__|___50 So, previous_sum is 0 in the beginning but ...

SQL Server 2005 - Incorrect syntax near '/'.

Here's a very easy question for someone :) Trying to update an SQL column with the following: UPDATE [NameOfTable] SET [HtmlContent] = 'a href=&quot;/sell-your-boat/&quot;' WHERE HtmlID = 123456 But am getting the following error message: Incorrect syntax near '/'. I know it's because I need to escape the / character but hitting my ...

SQL procedure where clause to list records

I have a stored procedure that will query and return records based on if items are available or not. That part is easy, Im simply passing in a variable to check where available is yes or no. But what I want to know is how do I throw a everything clause in there (i.e available, not available, or everything)? The where clause right now i...

Evaluating the mean absolute deviation of a set of numbers in Oracle

I'm trying to implement a procedure to evaluate the median absolute deviation of a set of numbers (usually obtained via a GROUP BY clause). An example of a query where I'd like to use this is: select id, mad(values) from mytable group by id; I'm going by the aggregate function example but am a little confused since the function need...