sql

What would be the sql to enter thousands of records into Oracle db with C#?

What would be the sql to enter thousands of records into Oracle db with C#? ...

How to handle HUGE SQL strings in the source code.

I am working on a project currently where there are SQL strings in the code that are around 3000 lines. The project is a java project, but this question could probably apply for any language. Anyway, this is the first time I have ever seen something this bad. The code base is legacy, so we can suddenly migrate to Hibernate or something...

Returning more than one value from a sql statement

I was looking at sql inner queries (bit like the sql equivalent of a C# anon method), and was wondering, can I return more than one value from a query? For example, return the number of rows in a table as one output value, and also, as another output value, return the distinct number of rows? Also, how does distinct work? Is this based...

Decision between storing lookup table id's or pure data

I find this comes up a lot, and I'm not sure the best way to approach it. The question I have is how to make the decision between using foreign keys to lookup tables, or just taking the lookup table value and inserting it into the table requesting the data when you have tables that are mostly based on existing data. Points to keep in ...

How to change the target table of a SQL insert statement?

How would you write a sql statement that allows you to insert data obtained from a form but will be entered in either one tabe or another depending on what is selected on the form? I know how to insert the data from a form to a specified table but I need to be able to use the form to select which table the data will be entered into. He...

SQL Data Transfer

Hi, I need to transfer data from one table to the same table in another server which has been truncated. Can somebody please, let me know the easiest way to do it. Please, help me. Thanks, Chris ...

Django objects.filter, how "expensive" would this be?

I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database server. soknad_lis...

Checking existance before inserting via Linq to SQL

I'd like to know if there's an easier way to batch insert a set of records if they don't already exist in a table. For example I have a Tags table in the database having ID, Name columns - given a list of tag names I want to add only those that are not already present. Here's what I came up with: private static void InsertTags(IEnumerab...

How to get latest record for each day when there are multiple entries per day?

I have table called dg like this: name kw date ---- --- ------------------- dg1 0 2008-10-16 01:08:09 dg1 213 2008-10-16 02:06:09 dg1 135 2008-10-16 23:05:09 dg1 0 2008-10-17 01:08:09 dg1 213 2008-10-17 02:06:09 dg2 0 2008-10-16 03:08:09 dg2 213 2008-10-16 04:0...

Strange Problem with updating Database from Dataset

Operations: Delete in DataGridView selected row from Dataset: FuDataSet.FuRow row = (FuDataSet.FuRow) ((DataRowView)FuBindingSource.Current).Row; row.Delete(); To add a new Row I'm doing: FuDataSet.FuRow row = FuDataSet.Fus.NewFuRow(); row.Someting = "Some initial Content"; row.SomethingElse = "More Initial Content"; ... FuDataSet.F...

SQL Query: Grouping by an ntext field

I have the below query, which basically it retrieves the 5 top most books sold: select top 5 count(id_book_orddetails) 'books_sold', bk.* from orderdetails_orddetails ord inner join books_book bk on ord.id_book_orddetails = bk.id_book group by id_book, name_book,author_book,desc_book,id_ctg_book,qty_book,image_book,isdel...

Trying to store XML content into SQL Server 2005 fails (encoding problem)

Folks, I have a webservice that returns data in ISO-8859-1 encoding - since it's not mine, I can't change that :-( For auditing purposes, I'd like to store the resulting XML from these calls into a SQL Server 2005 table, in which I have a field of type "XML NULL". From my C# code, I try to store this XML content into the XML field usi...

PHP and MySQL to design map search site

Hi Everyone, I have a project to designing a website to search Zip codes on a digital map. Somebody advised me to use PHP with postgreSQL or MySQL. My professor wants me to tell him why I chose this for a mapping site. The question is... Is there an expertise web language for GIS site ?? What is the difference if I use MySQL or MSsql ...

SQL a numbering column - MySQL

This is a sql newbie question. Basically, I want an extra column to return with my select statement to number the rows. I'm using mysql. Eg: select * from friends David Steve Joe What is the syntax to get: 1 David 2 Steve 3 Joe ...

Getting Hourly statistics using SQL

We have a table, name 'employeeReg' with fields employeeNo | employeeName | Registered_on Here *Registered_on* is a timestamp. We require an hourly pattern of registrations, over a period of days. eg. 01 Jan 08 : 12 - 01 PM : 1592 registrations 01 Jan 08 : 01 - 02 PM : 1020 registrations Can someone please suggest a query ...

How to Order a SQL Query with grouped rows

I have the table (Product_Id, category priority, atribute1, atribute2...) in MS Access, and I am trying to make a query that orders the data grouped by Category and ordered by the highest priority. Priority can be Null, so it should be placed at the end. Example: Table 1, 100, 2, atr1, atr2 2, 300, , atr1, atr2 3, 100, 5, atr1, atr2 4,...

Tagging sql statements for tracing and debugging

We have a large enterprise consisting of many apps both old and new backed by Oracle 10G. When blocking sessions or deadlocks occur and we get trace reports it would be super handy to be able to have embedded some details in the sql so that we know both what app, and specifically where it was executed from. In addition to helping speed...

select top 1000, but know how many rows are there?

SQL Server 2005 I have 10 million rows in DB, and run a select (with lots of "where" and joints.. pretty complex). The results are presented in grid (think goolge results) and because of that, the user cannot possibly use more then 1000 results. So I limit my SQL with a TOP 1000. Problem: User still wants to know that there are 5432 ...

How would I implement a simple site search with php and mySQL?

I'm creating a site that allows users to submit quotes. How would I go about creating a (relatively simple?) search that returns the most relevant quotes? For example, if the search term was "turkey" then I'd return quotes where the word "turkey" appears twice before quotes where it only appears once. (I would add a few other rules to...

SQL Precedence Matching

Hi All, I'm trying to do precedence matching on a table within a stored procedure. The requirements are a bit tricky to explain, but hopefully this will make sense. Let's say we have a table called books, with id, author, title, date, and pages fields. We also have a stored procedure that will match a query with ONE row in the table. ...