sql

Free SQL formatter tool

Hi, is there any free SQL formatter tool? I am using http://www.sqlinform.com/ for small queries. It is very good. But free version supports only 100 lines. TORA has the feature but it has many issues and I can not customize everything. Any free Eclipse plugins for this? ...

Constrain a table to have only one row

What's the cleanest way to constrain a SQL table to allow it to have no more than one row? This related question discusses why such a table might exist, but not how the constraint should be implemented. So far I have only found hacks involving a unique key column that is constrained to have a specific value, e.g. ALWAYS_0 TINYINT NOT N...

Searching a column containing CSV data in a MySQL table for existence of input values

Hi, I have a table say, ITEM, in MySQL that stores data as follows: ID FEATURES -------------------- 1 AB,CD,EF,XY 2 PQ,AC,A3,B3 3 AB,CDE 4 AB1,BC3 -------------------- As an input, I will get a CSV string, something like "AB,PQ". I want to get the records that contain AB or PQ. I realized that we've to write a MyS...

Table Partitioning

How advantageous is it to use partitioning of tables as compared to normal approach ? Is there a sort of sample case or detailed comparative analysis that could statistically ( i know this is too strong a word, but it would really help if it is illustrated by some numbers ) emphasize on the utility of the process. Thanks, Ankur ...

How to Configure and run DataBase Mail in SQL Server

How to enable and run Database Mail in SQL Server 2008 . I know that it need Enabling Service Broker Configuring SMTP (a Mail server is needed) Using Configuration Storeprocedure. I don't know what's the relation between application and dataBase mail. Actually How to enable Database mail for a RollBack and Commit Transaction ? (not f...

What is Service Broker ?

What is Service Broker in SQL Server and is it meaningful to enableitin a simple Database, Not in a distributed DB. please do not close this question, I saw others similar question and non of them answered me. ...

Using ROWLOCK in an INSERT statement (SQL Server)

Would it be wise to use ROWLOCK on an insert statement that is copying large amounts of data and inserting it into the same table? Ex) INSERT INTO TABLE with (rowlock) (id, name) SELECT newid, name FROM TABLE with (nolock) WHERE id = 1 Does anybody have recommendations on how to improve this statement, as I see when SQL S...

SQL 2005 optimal "Paging"

When creating a record "grid" with custom paging what is the best/optimal way to query the total number of records as well as the records start-end using C#? SQL to return paged record set: SELECT Some, Columns, Here FROM ( SELECT ROW_NUMBER() OVER (ORDER BY Column ASC) AS RowId, * FROM Records WHERE (...) )...

SQL help on a name dilemma

I have a column which has surname and firstname plus salutation in. e.g. Bloggs,Joe,Mr I need to break this out into Bloggs Joe Mr as 3 separate columns. Any ideas appreciated. The other thing is I won't know how many commas are in the initial column. ...

C# Getting Just Date From Timestamp

If I have a timestamp in the form: yyyy-mm-dd hh:mm:ss:mmm How can I just extract the date from the timestamp? For instance, if a timestamp reads: "2010-05-18 08:36:52:236" what is the best way to just get 2010-05-18 from it. What I'm trying to do is isolate the date portion of the timestamp, define a custom time for it to create a...

INSERT stored procedure does not work?

Hello, I'm trying to make an insertion from one database called suspension to the table called Notification in the ANimals database. My stored procedure is this: ALTER PROCEDURE [dbo].[spCreateNotification] -- Add the parameters for the stored procedure here @notRecID int, @notName nvarchar(50), ...

Select distinct values from multiple columns

I had a table (Some_Table) with two columns: A B ------------------- 1 test 2 test 3 test1 4 test1 i would like to return DISTINCT values for column B and it's associated value in column A (first in distinct set), so something like this: A B ----------- 1 test 3 test1 What is the sql? ...

Sqlite problem doing a Query

Hi all. Im triying to do a query on sqlite. I want to retrieve the server id of the servers that are not associated with a profile id (i have the id of the profile). The table serpro represents the n:n relationship betwen the tables. This is my query (apparently it is wrong): "Select server._id, server.server from server where server._...

Forming triangles from points and relations

Hello, I want to generate triangles from points and optional relations between them. Not all points form triangles, but many of them do. In the initial structure, I've got a database with the following tables: Nodes(id, value) Relations(id, nodeA, nodeB, value) Triangles(id, relation1_id, relation2_id, relation3_id) In order to gener...

VARCHAR does not work as expected in Apache Derby

I'm having this same problem: How can I truncate a VARCHAR to the table field length AUTOMATICALLY in Derby using SQL? To be specific: CREATE TABLE A ( B VARCHAR(2) ); INSERT INTO A B VALUES ('1234'); would throw a SQLException: A truncation error was encountered trying to shrink VARCHAR '123' to length 2. ...

SQL Exception: A truncation error was encountered trying to shrink VARCHAR '...' to length x

I know really little about sql, can anyone give me a deeper explanation (or references) of what do this exception means? --update data to add in VARCHAR is: 30819f300d06092a864886f70d010101050003818d00308189028181008942f81b3ae99e5f66dbc92cb971366f513c056e0bd6557c021058f6892d3a648230959c95378969f6dcb63046431fc0d39799789d307f96c811ae...

Get only latest row, grouped by a column

I have a large data-set of emails sent and status-codes. ID Recipient Date Status 1 [email protected] 01/01/2010 1 2 [email protected] 02/01/2010 1 3 [email protected] 01/01/2010 1 4 [email protected] 02/01/2010 2 5 [email protected] 03/01/2010 1 6 [email protected] 01/01/2010 ...

When is `x IS NOT NULL` not the same as `NOT(x IS NULL)`

For what x is The expression x IS NOT NULL is not equal to NOT(x IS NULL), as is the case in 2VL (quote from this answer, which is quoting Fabian Pascal Practical Issues in Database Management - A Reference for the Thinking Practitioner -- near the end of that answer) My guess is when x IS NULL is NULL, but I cannot guess when th...

Exclamation Marks in a Query SQL

I'm reading over this query, and I came upon a line where I don't understand heres the line [FETT List]![FETT Search] FETT List is a table FETT Search is a column in FETT List Can someone explain what the exclamation mark means? Thanks ...

Problem with connection to MS SQL Server database using SSMS

I have a database on line with Godaddy (who uses SQL Server 2005). They provide basic management tools, but tell you that for more advanced tools you can connect directly using SSMS. I followed their instructions to ensure my online database will accept remote connections, and can apparently log in using SSMS with success (after giving m...