sql

Advice on optimzing speed for a Stored Procedure that uses Views

Based on a previous question and with a lot of help from Damir Sudarevic (thanks) I have the following sql code which works great but is very slow. Can anyone suggest how I can speed this up and optimise for speed. I am now using SQL Server Express 2008 (not 2005 as per my original question). What this code does is retrieves paramet...

autoincrement in access sql is not working

How can I create a table with autoincrement in access. Here is what I have been doing but not working. CREATE TABLE People_User_Master( Id INTEGER primary key AUTOINCREMENT, Name varchar(50), LastName varchar(50), Userid varchar(50) unique, Email varchar(50), Phone varchar(50), Pw varchar(50), fk_Group...

SQL Query about blob length

Is there a way to query a MySQL database that gives me all blobs that are bigger than 1kb? ...

MySQL query for initial filling of order column

Sorry for vague question title. I've got a table containing huge list of, say, products, belonging to different categories. There's a foreign key column indicating which category that particular product belongs to. I.e. in "bananas" row category might be 3 which indicates "fruits". Now I added additional column "order" which is for dis...

make multiple, composite query in oracle

How can i make multiple, composite query in oracle? for example this several queries in one step? 1 CREATE TABLE test (id NUMBER PRIMARY KEY, name VARCHAR2(30)); 2 CREATE SEQUENCE test_sequence START WITH 1 INCREMENT BY 1; 3 CREATE OR REPLACE TRIGGER test_trigger BEFORE INSERT ON test REFERENCING NEW AS NEW FOR EACH ROW BEGIN SE...

SQL: Gather right hand values from a join

Let's say a question has many tags, via a join table called taggings. I do a join thus: SELECT DISTINCT `questions`.id FROM `questions` LEFT OUTER JOIN `taggings` ON `taggings`.taggable_id = `questions`.id LEFT OUTER JOIN `tags` ON `tags`.id = `taggings`.tag_id I want to order the results according to a particular tag nam...

can we list all tables in msaccess database using sql?

Can we find all tables in the msaccess using sql . as we do in sqlserver select * from sys.tables in sqlite SELECT * FROM sqlite_master where type='table' ...

Using normalize-string XPath function from SQL XML query ?

Hi, is it possible to run an SQL query, with an XPath "where" clause, and to trim trailing spaces before the comparison ? I have an SQL XML column, in which I have XML nodes with attributes which contain trailing spaces. I would like to find a given record, which has a specified attribute value - without the trailing spaces. When I tr...

T-SQL aggregate function Logical error

Hi Guys, Ok I have a data table containing duplicate Reciept numbers and a transaction value for each record, I need to simply list the total for each unique Reciept number, this is obviously a simple problem but I am missing something. Any help is much appriciated SELECT Gf_Receipt_number AS Reciept, SUM (Gf_Amount) AS Total ...

Odbc INSERT not working

Hey, im trying to get an INSERT command to work, but I keep getting the following error. Error: System.Data.Odbc.OdbcException: ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.90-community]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 'INSET INT...

Converting data in SQL Server

I am loading in a bunch of data that contains dates formatted as shown below: 00-JAN-0000 00-FEB-0000 00-MAR-0000 00-APR-0000 00-MAY-0000 00-JUN-0000 00-JUL-0000 00-AUG-0000 00-SEP-0000 00-OCT-0000 00-NOV-0000 oo-DEC-0000 SQL cannot automatically convert these dates because it does not recognize the month part of the date. I have appro...

SQL Query with conditional JOIN

The scenario: Table1 CatId|Name|Description Table2 ItId|Title|Date|CatId (foreign key) I want to return all rows from Table1 and Title,Date from Table2, where The returned from Table 2 must be the Latest one by the date column. (in second table there many items with same CatId and I need just the latest) I have 2 queries but can't...

vbscript/sql adding a column to an insert statement

I am trying to add an additional column and value to an existing insert query - both integers, and running into trouble. Anything to look out for? ...

How do I return count and not count in a SQL query?

Hi, If I have a table AgentID | IsNew | TeamID 1 N 1 2 Y 2 3 Y 2 4 N 2 5 Y 1 I want to return the following from a query: Team | CountIsNew = N | CountIsNew = Y 1 1 1 2 1 2 Is there a way I can do this? Using Oracle 10 ...

How do views reduce code duplication?

Hi! I read something like this about db views: Views are incredibly powerful and useful for one reason that stands out above all the other very good reasons. They reduce code duplication. That is, in most cases, the bottom line. If a query will be used in three or more places, then a view will drastically simplify your ...

Help Reading Binary Image Data from SQL Server into PHP

I cannot seem to figure out a way to read binary data from SQL server into PHP. I am working on a project where I need to be able to store the image directly in the SQL table, not on the file system. Currently, I have been using a query like this one: INSERT INTO myTable(Document) SELECT * FROM OPENROWSET(BULK N'C:\image.jpg',...

making sure "expiration_date - X" falls on a valid "date_of_price" (if not, use the next valid date_of_price)

I have two tables. The first table has two columns: ID and date_of_price. The date_of_price field skips weekend days and bank holidays when markets are closed. table: trading_dates ID date_of_price 1 8/7/2008 2 8/8/2008 3 8/11/2008 4 8/12/2008 The second table also has two columns: ID and expiration_date. The expira...

Beginning with SQL

Hey ALL; I am enthusiastic to enter the world of Databases through SQL , but i don't know if there's pre-requisits of any significance , i only know c# and java . Besides what tools do i need? i have visual studio 2008 and sql server management studio what else do i need? is it necessary to download a server OS? Bare with me i'm j...

Best way to describe variable types in SQL

Hello, What is the best way to translate the following problem in SQL table structure: In a file transfer application, I have a master table with an "Upload type" field. Depending on the value of that field (FTP, SFTP, HTTPS, FS copy) the record is to be linked with other entries in the appropriate table (FTPsites, HTTPSSites, etc.) co...

Is it possible to write a SQL query to return specific rows, but then join some columns of those rows with another table?

I'm having trouble wrapping my head around how to write this query. A hypothetical problem that is that same as the one I'm trying to solve: Say I have a table of apples. Each apple has numerous attributes, such as color_id, variety_id and the orchard_id they were picked from. The color_id, variety_id, and orchard_id all refer to thei...