sql

SQL Server : Join

Hi All, First two column is from one set of query statements and the remaining from other set. I want to display the values in a single row. Can anybody help me A B C D NULL NULL 0 22 0 699 NULL NULL SELECT statement: SELECT P.A, P.B, T2.C, T2.D FROM Table1 AS P JOIN ( SELECT MAX(ID) ID, COU...

Custom SQL queries in PerformancePoint DashBoard designer

Is it possible to utilize the data that is returned by a CUSSTOM SQL query on a database to create the DasshBoard elements ? So far i was ablle to connect to a specific Table and use it in AS IS form ( no interaction with multible tables ) Any pointers in this topic would be much appreciated. Thanks, IP. ...

How to optimize Entity Framework Queries

I am using Linq-To-Entities to do a query which is returning only 947 rows but taking 18 seconds to run. I have done a "ToTraceString" to get the underlying sql out and ran the same thing directly on the database and get the same timing. I have used the tuning advisor and created a couple of indexes although with little impact. Lookin...

Sql trying to change case letter and group similar nvarchar values

Hi you guys. I am using sql server 2008 and I'm trying to build a query for displaying some overall results from a single sql table. I want to display count(fieldname) for each date, for example I want to know how often the name "izla" is repeated in the table for each date but it could be also "IZLA" or "Izla", so i must find a way to...

delete from two tables in one query

hi , i have two tables in mysql #messages table : messageid messagetitle . . #usersmessages table usersmessageid messageid userid . . now i want to delete from messages table it's ok . but when i delete message with messageid='1' for example it's still exists on usersmessage i have to delete from this two tables at once ; s...

Connection Lifetime=0 in MySql connection string

What exactly does Connection Lifetime=0 mean in a connection string? ...

how to get current datetime in SQL?

Want to get current datetime to insert into lastModifiedTime column. I am using MySQL database. My questions are: is there a function available in SQL? or it is implementation depended so each database has its own function for this? what is the function available in MySQL? thanks, ...

MySQL INSERT INTO ... SELECT #1054 ERROR

Can anybody please help.. SELECT on its own works INSERT on its own with VALUES works also. note: products_similar has 2 columns VARCHARS get_cheaper() - stored routine returning VARCHAR I never ever had problems with INSERT INTO ... SELECT. But when I combine them I get error below: SQL query: Documentation INSERT INTO `produ...

Selecting items IN a row

Hi there, I'm developing a website for Tenants to find properties. When they sign up, they can choose the property types that they are interested, for example: Apartment or House. When a Tenant logs into their account, they can then do a search for properties. The search form is prepopulated with the values that they originally entered...

Is there a nesting limit for correlated subqueries in Oracle?

Here is the code that will help you understand my question: create table con ( content_id number); create table mat ( material_id number, content_id number, resolution number, file_location varchar2(50)); create table con_groups (content_group_id number, content_id number); insert into con values (99); insert into mat values (1, 99, 7,...

SQL - Optimizing performance of bulk inserts and large joins?

I am doing ETL for log files into a PostgreSQL database, and want to learn more about the various approaches used to optimize performance of loading data into a simple star schema. To put the question in context, here's an overview of what I do currently: Drop all foreign key and unique constraints Import the data (~100 million reco...

"no descriptor for this position" Oracle error

We're trying a basic insert statement: INSERT INTO HOLIDAY (HOLIDAY_TYPE_CODE, CALENDAR_NAME, HOLIDAY_DATE, DESCRIPTION, CREATE_TS, UPDATE_TS) VALUES (2, 'CZK', '17-NOV-2009', NULL, SYSDATE, NULL); And we get this error: ORA-24334: no descriptor for this position What are we doing wrong here?? ...

SQL Selecting finished orders with multiple operations

I have a list of orders with suboperations. How can I create a list of finished orders? Finished order must have finished all suboperations. Table "orders": order_no | suboperation | finished 1 | preparing | 01/01/2009 1 | scrubbing | 01/05/2009 1 | painting | 01/10/2009 2 | preparing | 02/05/09...

Could not obtain information about Windows NT group user

I am creating a SQL Server Replication using a script. When I try to execute The job failed. Unable to determine if the owner (STAR\moorer7) of job L3BPT2M-Atlas-14 has server access (reason: Could not obtain information about Windows NT group/user 'STAR\moorer7', error code 0x5. [SQLSTATE 42000] (Error 15404)). This is a job created...

How to avoid repeating a lengthy CORRELATED subquery?

Here is the code to help you understand my question: create table con ( content_id number); create table mat ( material_id number, content_id number, resolution number, file_location varchar2(50), file_size number); create table con_groups (content_group_id number, content_id number); insert into con values (99); insert into mat values...

How to handle multiple one->many relationships?

I have a database with several tables, 5 of which are dedicated to specific publication types. Each of these 5 have a one->many relationship with a status table and a people table. All of these tables are tied together using a unique "pubid". I have a view which includes the pubid (for all 5 types), along with their associated keyword...

Polymorphic Rails Associations (going backwards?)

Hi, I have a many to one polymorphic rails association in my rails app for a 'case' model. There are many things that have cases, so I access the case each thing has by doing 'thing_that_has_a_case.case'. However, I'm trying to go the other way and I'm not sure how. I have access to the case object but I want to access the thing tha...

SQL Reporting Services and Excel

The basic setup is that I have a web application that calls SQL Reporting Services to run reports. The reports have the option of returning in PDF or Excel format. The code in the background runs the report, gets the results and writes it out using httpResponse.BinaryWrite(). Most of the reports work fine. IE recognizes the excel fil...

CREATE OR REPLACE VIEW sql error

Trying to update a table view using: CREATE OR REPLACE VIEW [vtable] AS SELECT * FROM Files_Table ORDER BY File The table is returning the old view, not the updated. Statement tested in the Sqlite database browser: Error message from database engine: near "OR": syntax error but didn't get this in the program? Any idea why i...

mysql query with group by and order by

I have a table like this: .--------------------------------. | Name | XX | Date | .--------------------------------. | N1 | 5 | 2009-05-01 | | N1 | 10 | 2008-01-08 | | N2 | 8 | 2009-02-02 | .________________________________. My result should be this: .------------. | Name | XX | .-------...