sql

ROW_NUMBER() OVER Not Fast Enough With Large Result Set, any good solution?

I use ROW_NUMBER() to do paging with my website content and when you hit the last page it timeout because the SQL Server takes too long to complete the search. There's already an article concerning this problem but seems no perfect solution yet. http://weblogs.asp.net/eporter/archive/2006/10/17/ROW5F00NUMBER28002900-OVER-Not-Fast-Enoug...

Selecting rows connected with set of rows from second table

I have three tables: project (idproject, name) color (idcolor, name) project_has_color (idproject, idcolor) Now I need to select projects connected with set of colors, for example: blue (1), red (2), green (3): SELECT p.idproject, p.name FROM project p, project_has_color c WHERE p.idproject=c.idproject AND c.idcolor IN (1,2,3) gi...

Is php deg2rad() equal to mysql radians()

Are these functions the same? If not, what is an appropriate php equivalent to mysql's radians() ...

Does index on Varchar make performance difference?

Does index on a varchar column make the query run slower? I can make that be int. and I don't need to do the LIKE % comparison. ...

complete sync between iphone sqlite3 database to sql server 2005 database on the server

Hi, I hava a sqlite3 database placed in the documents folder. I need to sync this database with the sql server 2005, which is running at our server. Is there a possibility that i can do a Replication between a sqlite3 database and a MSSql server 2005. -- Regards, Syed Yusuf ...

How do I refactor this SQL query?

Hi, I have a table called users with a column called activated_at, and I want to count how many users have been activated by checking if the column is null or not. And then display them side by side like this: +----------+-----------+---------------+-------+ | Malaysia | Activated | Not Activated | Total | +----------+-----------+-----...

Search in more than one table - give result as one column.

Hey stackoverflow - This is my first question here. I have 2 tables in my mySQLdb. [tab_artist] |id|artist|count [tab_songtitle] |id|songtitle|artistId Im trying to select from both tab_artist.artist and tab_songtitle.songtitle as suggest where searchclause = m I have tried this SELECT artist, songtitle AS suggest FROM tab_ar...

Optimize SQL SELECT for 4000 searches, into Excel by VBA

How could this be optimized for speed by batching or other techniques? Its a 20MB Access2003 Database I am searching from Excel 2003 VBA. I have my Access Table Keyed (autonumber) so I though this would provide intelligent non-linear searching like binary searches. Currently searching for 4000 values from a table of 147k records is ta...

Joining two tables using column which has duplicate values, master -lookup tables

I have a table (x) which has 9 million rows and one of its columns is cosub which has repeating duplicate values, there is another table (y) which has related details for cosub it has 59k rows and additional columns that provide details related to cosub (acting as lookup table) how can i join the two tables, querying 9 million rows and ...

Unique date range fields in SQL Server 2008

I have a table that consists of, among other things, two fields named StartTime and EndTime. Both are TIME fields. I want to add a constraint preventing the insertion of any records that overlap with preexisting time ranges. E.g. if a record already exists with StartTime = 5:00, EndTime = 10:00, I would want an insert with StartTime = 6...

solution for ORA-00933

I'm tring to use join but facing this issue. I've pasted my query select count(*) from table_a inner join table_b on table_a.number = table_b.number left outer join table_c on table_a.id = table_c.id and table_a.number = table_c.number order by number; pls let me know ...

Can I temporarily store data in my C#.Net app to reduce the need for calls for data from SQL Server?

I created a C#.net app that uses dates from a sql server 2008 database table. Is there a way for me to temporarily store the data so that my program does not have to repeatedly make server calls for the same set of information. I know how to pull the info I need and create a temporary dataset, however, it is only accessable to the part...

PHP OOP Design for simple Models

Hi, i've a little problem with the proper design for some simple database models. Lets say i have an User Object with getter/setters and an read method. Read querys the database and sets the properties. class User extends MyDbBaseClass { protected $_id; protected $_name; public function setId($id) { $this->_id = $id; } public funct...

Changing date format from date field in database.

I am using ASP.NET with SQL Server 2005. My date get saved in the database with data type = "smalldatetime". I am displaying the date value into a text box called txtDate with a Reader...... Dim conn As Data.SqlClient.SqlConnection Dim Comm As Data.SqlClient.SqlCommand Dim reader As Data.SqlClient.SqlDataReader conn =...

How do I convert this to use JOINS?

How do I convert this to use JOINS? SELECT j.job_id, j.name AS job_name, a.name AS advertiser_name, j.time_added, j.active, j.moderated FROM jobs j, advertisers a WHERE a.advertiser_id = j.advertiser_id ...

SQL Server database script

i need a script to script all the database object (like tables,sp,view).....like IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fnSplit]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT')) DROP FUNCTION [dbo].[fnSplit] GO /****** Object: UserDefinedFunction [dbo].[fnSplit] Script Date: 12/14/2009 ...

Get over points

Hello, I am writing a function to get overall score in SQL What I have is; out of 20 points I got 12.4 points so if I transform that, to take percentage over 100% how would I do it? Thanx, Adnan ...

sometimes Identity isn't working.

Hi, I have a following table CREATE TABLE [dbo].[test_table] ( [ShoppingCartID] [int] IDENTITY(1,1) NOT NULL, [CartTimeoutInMinutes] [int] NOT NULL, [MaximumOrderLimitPerUser] [int] NOT NULL, [MaximumOrderLimitPerSession] [int] NOT NULL, CONSTRAINT [PK_test_table] PRIMARY KEY CLUSTERED ( [ShoppingCartID] ASC ) WITH (PAD_INDEX = ...

How do I implement pagination in SQL for MS Access?

I'm accessing a Microsoft Access 2002 database (MDB) using ASP.NET through the OdbcConnection class, which works quite well albeit very slowly. My question is about how to implement pagination in SQL for queries to this database, as I know I can implement the TOP clause as: SELECT TOP 15 * FROM table but I am unable to find a way to ...

Left join not pulling through nulls where expected.

I have a query that looks something like this (I've changed the table names): select @user_id , isnull(ur.rule_value, isnull(manr.rule_value, def.rule_value)) [rule_value] , isnull(urt.name, isnull(manrt.name, def.name)) [rule_type] from (select @user_id [user_id] , rule.rule_value , rule_type.name fr...