sql

Is there a right way to retrieve a String field in SQL

I have seen different ways to retrieve a string field from SQL. Is there a "right" way, and what are the differences SqlDataReader rdr; 1. String field = (String) rdr["field"]; 2. String field = rdr["field"].ToString(); 3. String field = rdr["field"] As String; Thanks! ...

datetime vs timestamp?

What would you recommend using between a datetime and a timestamp field, and why? (using mysql). I'm working with php on the server side. ...

MySQL Simple Forum

So I'm trying to build a simple forum. It'll be a list of topics in descending order by the date of either the topic (if no replies) or latest reply. Here's the DB structure: forum_topic id, name, email, body, date forum_reply id, email, body, date, topic_id The forum itself will consist of an HTML table with the following h...

Sql, selecting and updating

Hi, I am trying to select 100s of rows at a DB that contains 100000s of row and update those rows afters. the problem is I don't want to go to DB twice for this purpose since update only marks those rows as "read". is there any way I can do this in java using simple jdbc libraries? (hopefully without using stored procedures) update: ...

PostgreSQL query inconsistency

Hi again, I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page, pagelinks WHERE (page.page_namespace <=3 OR page.page_namespace = 12 OR page.page_namespace = 13 ) AND (pagelinks.pl_namespace <=3 OR pagelinks.pl_namespace ...

Optimization techniques for large databases

What optimization techniques do you use on extremely large databases? If our estimations are correct, our application will have billions of records stored in the db (MS SQL Server 2005), mostly logs that will be used for statistics. The data contains numbers (mostly integer) and text (error message texts, URLs) alike. I am interested in...

A source to learn database design

I am looking to make a website and in the future desktop apps as well and i know nothing about db design so what tutorials or books (online preferably) are there? thanks ...

Flex Matching Many Database Records (Quicksilver-like or Launchy-like matching)

Assume I have a database table with many names. I'd like to "flex match" against these names. I'm not sure if "flex match" is the proper term to use, but let's go with that for now. There have been similar discussions on "fuzzy matching," but I'm not really interested in phonetic matching. I'm interested in what I'd call ordered-subs...

Inserting data into SQL Table with Primary Key. For dupes - allow insert error or Select first?

Given a table such as: CREATE TABLE dbo.MyTestData (testdata varchar(50) NOT NULL) ALTER TABLE dbo.MyTestData WITH NOCHECK ADD CONSTRAINT [PK_MyTestData] PRIMARY KEY CLUSTERED (testdata) And given that we want a unique list of 'testdata' when we are done gathering items to be added from a list of external data with known duplicates...

Optimal LIKE search in SQL

I have a parts database that I am going to be constantly querying for a quoting system. The parts database has 1,400,000+ records in it. The users are just going to start typing part numbers, which they expect the system to be able to find after only a few characters, so I need to be able to do a wildcard search, something like: SELEC...

Application execute complex SQL query

My application needs to execute a fairly complicated series of queries against a database. Normally I would just dump everything into a stored procedure and execute it that way. But I do not have access to the database I'm trying to access so I can't create a stored procedure. Is there a better way of doing this instead of hitting t...

NHibernate query with distance calculation stored proc

I have a stored procedure in my database that calculates the distance between two lat/long pairs. This stored procedure is called "DistanceBetween". I have a SQL statement allows a user to search for all items in the Items table ordered by the distance to a supplied lat/long coordinate. The SQL statement is as follows: SELECT Items.*, d...

Is it possible to perform multiple updates with a single UPDATE SQL statement?

Let's say I have a table tbl with columns id and title. I need to change all values of title column: from 'a-1' to 'a1', from 'a.1' to 'a1', from 'b-1' to 'b1', from 'b.1' to 'b1'. Right now, I'm performing two UPDATE statements: UPDATE tbl SET title='a1' WHERE title IN ('a-1', 'a.1') UPDATE tbl SET title='b1' WHERE title IN ('b-1',...

create sql query in c++/java?

which method do you prefer for creating dynamic sql queries? formating or streaming? Is it just preference or there any reason one is better than other?Or any special library you use to it. EDIT: Please answer in case of c++. ...

LINQ ISNULL

In SQL you can run a ISNULL(null,'') how would you do this in a linq query? I have a join in this query: var hht = from x in db.HandheldAssets join a in db.HandheldDevInfos on x.AssetID equals a.DevName into DevInfo from aa in DevInfo.DefaultIfEmpty() select new { AssetID = x.AssetID, Sta...

Sparse data: efficient storage and retrieval in an RDBMS

I have a table representing values of source file metrics across project revisions, like the following: Revision FileA FileB FileC FileD FileE ... 1 45 3 12 123 124 2 45 3 12 123 124 3 45 3 12 123 124 4 48 3 12 123 124 5 48 3 12 123 ...

How long would it take a non-programmer to learn C#, the .NET Framework, and SQL?

I am not that good at programming. I finished my masters degree in electronics. I want to learn C#, the .NET Framework, and SQL. How much time do you think it would take (if I have 5 hours a day to devote to it)? Also, what order do I learn them in? I have Visual Web Developer 2008, is that enough to begin? Copied from a new question b...

SELECT * EXCEPT

Is there any RDBMS that implements something like SELECT * EXCEPT? What I'm after is getting all of the fields except a specific TEXT/BLOB field, and I'd like to just select everything else. Almost daily I complain to my coworkers that someone should implement this... It's terribly annoying that it doesn't exist. Edit: I understand e...

How can I prevent/detect an underflow in a Postgresql calculation that uses EXP()

I am receiving a value out of range: underflow error from pgsql, in a query that uses the EXP(x) function. What values of x trigger this? How do I prevent or detect it? ...

Filtering With Multi-Select Boxes With SQL Server

I need to filter result sets from sql server based on selections from a multi-select list box. I've been through the idea of doing an instring to determine if the row value exists in the selected filter values, but that's prone to partial matches (e.g. Car matches Carpet). I also went through splitting the string into a table and joini...