sql

MYSQL with Coldfusion - Solutions to create Search Capabilites?

I'm using MySQL & ColdFusion. Currently for searching TEXT fields I'm using LIKE in the database. Luckily my database is empty but soon the table will fill up and I fear I the LIKE SQL query will kill my app. I'm looking for a solution that works with both MySQL & ColdFusion that will allow me to scalably offer search capabilities with ...

Improve SQL query: Cumulative amounts over time

Suppose I have a SQL table of Awards, with fields for Date and Amount. I need to generate a table with a sequence of consecutive dates, the amount awarded in each day, and the running (cumulative) total. Date Amount_Total Amount_RunningTotal ---------- ------------ ------------------- 1/1/2010 100 ...

How to find the usage of constant in sql server database

Is there a way to search through the set of (Stored Procedures, Functions, Views) for the usage of a constant? I have a problem where I've got a sql server database. It has quite a few stored procedures and functions declared. I'm looking for the usage of "115", which happens to be a pay code. I didn't write all of the code origina...

SQL Server 2005 - how to know if a field is a Primary Key?

If I have the name of a field is there away to know (lookup?) whether this is a PK and if so in which table? ...

oracle date range

Hi, using a Oracle 10g db I have a table something like this: create table x( ID NUMBER(10) primary key, wedding DATE NOT NULL ); how can I select * from x where wedding is in june 2008??? I know it is probably an easy one but I couldn't find any satisfying answer so far. Help is very much appreciated. ...

"Back to search results" problem

I have a form with many inputs, but not all inputs must be filled in. Form action is set to a php file, which checks which inputs are set and builds a query to query MySQL. Then I display the results on the main page, and the users may click on an ad to show. When clicked an ad, a new page opens with several options for the user (chang...

Why can I use SELECT but not INSERT on a SQLite database in PHP?

I am able to retrieve information from a SQLite database in PHP, but not write to it. For example, this code works perfectly fine: $db = new PDO("sqlite:foo.db"); $rowCount = $db->query("SELECT COUNT(*) FROM tblname;")->fetchColumn(0); echo $rowCount; // works as it should However, the following snippet results in an, 'unable to open ...

DataDeduplication idea

Good morning Just built a small Data De-duplication chunk of code in C# and want to check if anyone has done something simular before, and if so, how? is there publicly available code for this? The code i wrote is on GitHub at http://gist.github.com/273880. At the moment, there is no physical backing store, and no way of storing what...

Best approach, Dynamic OpenXML in T-SQL

hello, i'm storing XML values to an entry in my database. Originally, i extract the xml datatype to my business logic then fill the XML data into a DataSet. I want to improve this process by loading the XML right into the T-SQL. Instead of getting the xml as string then converting it on the BL. My issue is this: each xml entry is dynami...

LINQ to SQL performance with "SELECT TOP {x}" queries

In looking up how to perform an equivalent to SELECT TOP 5 with LINQ-to-SQL, all the answers I've seen suggest using .Take(), like so: var myObject = ( from myObjects in repository.GetAllMyObjects() select myObject) .Take(10); I don't yet understand most of how LINQ works behind-the-scenes but to my understanding of C-like languages t...

How can I tell LINQ to construct my entities with my own query data

I know it will sound strange but please don't mind: In C#, let's say I manually do with ADO or anything else: SELECT * FROM Member Then I want LINQ to construct my Member entities from the data I just retrieved myself from the query... Do you have an idea if it's possible? Thanks ...

Modifying value of ntext column

I have a column in ntext which holds large unicode strings longer than 4000 chars in length. I need to update/modify the data of the rows of the column in sql but I have no clue how to do so. I have tried nvarchar(max) as a buffer but it truncates the data into 4000 chars. Could anyone help me give me a hint or an idea or a workround so...

why we use an ID column in the table if we have a unique value

hello i want to ask a small question here but i really don't know what is the answer of this question. i have a accounts table which has Username | Password the username is a primary key so its unique so is it necessary to put an ID column to the table ? if Yes, what is the benefit of that ? Thanks ...

how do I get month from date in mysql

I want to be able to fetch results from mysql with a statement like this: SELECT * FROM table WHERE amount > 1000 But I want to fetch the result constrained to a certain a month and year (based on input from user)... I was trying like this: SELECT * FROM table WHERE amount > 1000 AND dateStart = MONTH('$m') ...$m...

Mysql delete query deletes only two columns in a row...!!

Hi all... I have a table with the following structure.... FIELD TYPE EXTRA faciltiy_id int auto_increment(Primary Key) hotel_id int facility_title varchar(20) facility_desc varchar(300) When i want to delete a row with a particular facility_id i use the code.... DELETE FR...

difference between stored procedures and user defined functions

Can anyone please explain what is the exact difference between stored procedures and user defined functions and in which context what is useful? ...

sql closed loop relations; what could go wrong?

Hi, I am working with a database with the following design. I read it is not a good practice to have closed loops in a database design, and i have more than one. But i cannot remember why. So not sure how this might affect me. Any examples how this could be dangerous? Edit: went through my ebooks, found what i was reading was Begin...

SQL ERD newbie question

Hi, If I have a datawarehouse erd - which has the relationsips etc How will i know what type of join to use , inner, outer left, outer right, full outer,, surely if the database has been created correctly they all would be inner joins ? bar data quality issues ...

SplitValue function in sql server2008

Hello, I found some table valued function for splitting string in sp and getting values in columns, but when data is huge these functions are became slow. so if anybody has a good function for splitting values separated by commas into rows of a table... please provide me. The link where I found some functions: Click Here ...

Howto recursively update groups in SQL Server

I'm using sql Server 2008. following dataPool: PK Col1 Col2 1 SomeValue1 DataToTake1 2 SomeValue1 3 SomeValue1 4 SomeValue1 5 SomeValue2 DataToTake2 6 SomeValue2 ... i want to insert DataToTake1 into Col2 of records with PK 2, 3 and 4 and DataToTake2 into Col2 of record with PK 6. to make it more obvious: record...