sql

Oracle 9i: How can I determine, using metadata, whether or not an index is clustered?

The question pretty much sums this up, but I'll provide some more details. I can almost safely assume that any primary key index in an Oracle database is clustered. But I'm not one to assume. Besides, a user might have created a clustered index that wasn't the primary key. If that's the case, I'd really like to know. So, in the interes...

Is it better to use a prepared Select statement when you are only doing one select?

I am currently writing a CRUD class in PHP using PDO. I like the security that prepared statements provide, but I have heard that they also prevent databases like mysql from using the queryCache. Is it better to use a prepared Select statement when you are only doing one select at a time? or would just $pdo->quote() suffice the securit...

How to delete Duplicates in MySQL table.

I've given a client the following query to delete duplicate phone no. records in an MSSQL database, but now they need to also do it on MySQL, and they report that MySQL complains about the format of the query. I've included the setup of a test table with duplicates for my code sample, but the actual delete query is what counts. I'm aski...

Where's the tradeoff between normalization (SQL View) and performance/fiability (SQL Table)

I've got quite a long business process which eventually results into financial operations. What matters in the end is quite exclusively these final operations, although I've got to keep a log of everything which led to it. Since all the information contained into the final operations is available in other tables (used during the busine...

LIMIT in FoxPro

I am attempting to pull ALOT of data from a fox pro database, work with it and insert it into a mysql db. It is too much to do all at once so want to do it in batches of say 10 000 records. What is the equivalent to LIMIT 5, 10 in Fox Pro SQL, would like a select statement like select name, address from people limit 5, 10; ie only ...

how to assign default value to timestamp datatype in c#?

i want to do above. i have an object of table in c#. ...

SQL Server 2005 "FOR XML PATH" Multiple tags with same name

I have an XML structure like the following <root> <person> <name>James</name> <description xsi:type="me:age">12</description> <description xsi:type="me:height>6 foot</description> ... Which I have to pull out of a table like ... Person Name , Age , Height I'm trying to use the FOR XML path stuff in SQL 2...

Stored procedures and the tables used by them

Hi people! Is there a way to know what are the tables used by one stored procedure by doing an SQL query? Best regards, and thanks for the help. P.S.: I'm using SQL Server 2005. ...

Is a duration of 394 when executing a SQL query too much?

I had this connection pool problem: How to solve a connection pool problem between ASP.NET and SQL Server? And I am now tracing using the SQL profiler, and I found some queries take about 400 duration to finish and return data. Is that value too much? Could it cause the previous connection pool problem? ...

Modulo arithmetic on dates in SQL

I have a system which defines repeating patterns of days. Each pattern has a base date (often a few years in the past, when the pattern was created) and a day count (which loops), so for example it might define a pattern for a seven day period: Table: Pattern ID | BaseDate | DayCount ----------------------------- 1 | 01/02/2005 | 7 ...

Is more than 100 active connection to SQL server db not normal in an ASP.NET website?

While tracing the active connection on my db i found that some times the connections exceeds 100, is that normal? and after few minutes it return back to 20 or 25 active connection more details about my problem Traffic on the site is around 200 visitor per day. Why i am asking? because the default MaxPool in the asp.net connection strin...

How to find the *position* of a single record in a limited, arbitrarily ordered record set?

MySQL Suppose you want to retrieve just a single record by some id, but you want to know what its position would have been if you'd encountered it in a large ordered set. Case in point is a photo gallery. You land on a single photo, but the system must know what its offset is in the entire gallery. I suppose I could use custom indexin...

DataTable.Select Expression using IN and Like.

Greetings, I have two questions regarding a DataTable.Select(): 1) How to escape potential apostrophes or any other characters that would cause an issue. I'm not worried about SQL Injection. 2) How to use IN with Like, and include results that have a null. 1) Unfortunately, I can't seem to find any advice for the first option since...

Dynamic creation of new lookup tables based on values in main data table

I am working on an application which accepts any uploaded CSV data, stores it alongside other datasets which have been uploaded previously, and then produces output (CSV or HTML) based on the user selecting which columns/values they want returned. The database will be automatically expanded to handle new/different columns and datatypes ...

XML Reader on SQL Table returning invalid XML

I have SQL table that has a varchar(8) column that occasionally has binary data in it. (0x01, 0x02, etc...). (Changing the format or the content of the column isn't an option.) When I go into the SQL Server 2005 Management Studio and run the query: select * from mytable where clientID = 431620 for xml auto I get useful results...

Problem Query

Hi, Basic need is if a record has an Attribute of "Urgent", then the attributevalue should be displayed in the Urgent column. If the record has an attribute value of "closed", then the attributevalue must be displayed in the "Closed" column. I have a query below. My problem is that among the results I am getting back, there are two rec...

Select COUNT() from multiple databases in SQL

Hello, I am attempting to return the number of customers located in a specific state that have rented a specific movie, where the rents table contains two columns, one for customer ID and one for the movie ID. The function takes in a movie ID and the state and returns an integer with the amount of customers. Right now I have an implemen...

group-by question in postgresql

Say I have a table 'orders' created as: CREATE TABLE orders (id SERIAL, customerID INTEGER, timestamp BIGINT, PRIMARY KEY(id)); Timestamp being the UNIX timestamp. Now i want to select the ids of the LATEST orders for every customer. As a view would be nice. however the...

SQL 2000 single mode, related to database dbcc checkdb

I am trying to hack opening a MDF file in a new database. We lost the backup. After reading numerous articles, I came to the point where the only thing that separates me from a successful solution is setting the db into a single user mode. I issue "sp_dboption 'MyDbName',single,true" SQL Server reports that "The command(s) completed su...

Can you use LINQ with in memory objects rather than SQL Server queries to improve performance?

We have been developing a DB web app which constantly queries an SQL store of objects (about 80,000 of them) which are related to each other in a hierarchy. (i.e. many objects have parentid which relates to another object in the same table) I have been thinking that loading the entire object tree into memory and querying the objects usi...