Hello, and thanks for reading.
I'm making a DB for a puppy shop. I have a table for puppies and a table for owners. A puppy can have one owner, owners can own more than one puppy, but not all puppies are owned. What's a good way to handle this situation?
Do I use a FK in the puppy table that is NULL if the puppy doesn't have an owne...
I have a table with one DateTime column. I want to find the rows with lowest time which their times are more than a variable myTime.
How can I do that?
What kind of index will increase the performance?
...
I have a String field where I store two-word area names.
Ex: New York
Thing is, whenever I try to query that field (area:New York) no results come up, even though it is stored exactly as New York.
Why is this?
The results DO come up if I search like this: area:"New York" but they wont come up if searching like this: area:New.
Any id...
Question
How can I alter the SQL code below to ensure that the inserts into "dbo.tblBootStrapperInstruments" only occur if they don't already exist?
Code
INSERT INTO dbo.tblBootStrapperInstruments (CCY, Instrument, Tenor)
SELECT CCY,Instrument,Gridpoint FROM dbo.Feed_Murex_Intraday_DF mx WHERE NOT EXISTS
(SELECT * FROM dbo.tblBootStr...
I perform an insert as follows:
INSERT INTO foo (a,b,c)
SELECT x,y,z
FROM fubar
WHERE ...
However, if some of the rows that are being inserted violate the duplicate key index on foo, I want the database to ignore those rows, and not insert them and continue inserting the other rows.
The DB in question is Informix 11.5. Curre...
I have this data. I need to get the lowest $ full rows for each person.
Amount Date Name
$123 Jun 1 Peter
$120 Jun 5 Peter
$123 Jun 5 Paul
$100 Jun 1 Paul
$220 Jun 3 Paul
The result of the SQl Server query should be:
$120 Jun 5 Peter
$100 Jun 1 Paul
...
This is an in-depth continuation of my question from earlier this morning, which I'm still stumped about. I'm using a strongly typed DataContext for my application and although it emits a warning, it magically works. How does it do this?
Here's the code one would typically use to connect to a database using LINQ-to-SQL.
class MyDatabas...
In the past I have just added an field to each table and updated it with GETDATE() on every update/insert. The problem is now I have to keep track of delete too. I was thinking of just having a table that I would update when anything changed and add a trigger to all of the other tables. Ideas??? Thanks!
...
I have a query like this:
SELECT TOP 1 ID, DATA, OTHERINF FROM MYTABLE WHERE DATE = @DATE
and after reading the row data and using it I want to update that retrieved row and change one of it's columns (in another transaction).
But as you see here i searched for that row twice. Is there anyway that I keep remember the row and do the u...
I'm using SqlBulkCopy to bulk insert some records from one table into another table. The query is using a SqlDataReader to get the data. The one difference that matters (besides column order which is handled in the mappings) between the tables is that the destination table has a date column into which the current date needs to be added...
Does having a primary key column mean there is an index on that column? If so, what kind of index is it?
...
I'm running a software called Fishbowl inventory and it is running on a firebird database (Windows server 2003) at this time the fishbowl software is running extremely slow when more then one user accesses the software. I'm thinking I maybe able to speed up the application by forcing the database to run "In Memory". However I can not fin...
MySQL 5.0.45
Table A has the following fields (columns):
1. transcation_id
2. client_name
3. item_id
4. .....
Now I need to find how many transactions each client has made order by # of transactions. The result should be like:
Tom 7 transactions
Jack 5 transactions
Mike 2 transactions
If a client has no transactions his n...
Can a Superkey include things that aren't part of the Primary key?
...
Running SQL Server Integration Services (64-bit install of SQL Server 2008 Developer) on a 64 bit version of Windows 7 Professional.
I have a simple SSIS package which imports data from a delimited text file, does a lookup to a SQL Server table, joining on a key field (int) and returns the UserName (varchar(50)) from that table.
Sample...
SELECT DISTINCT u.UserID, UserLastName, UserFirstName, UserName, Notified,
MAX (CycleNumber) as CycleNumber, (CycleCurrentStep) as CycleCurrentStep,
MAX (CycleDateReported) as CycleDateReported,
max (cycleid)
FROM [User] u
left join Cycle c on (u.UserID = c.UserID)
join UserDivSection us on (u.UserID = us.UserID
and us.DivSection...
I'm running a software called Fishbowl inventory and it is running on a firebird database (Windows server 2003). At this time the fishbowl software is running extremely slow when more then one user accesses the software. I'm wondering if anyone could provide some information on tuning the database or best practices? We are currently runn...
How do you add a unique constraint in SQL Server 2005 to two columns? So lets say that I have:
PK, A, B ...
x1 1 1
x2 1 2
x3 2 1
x4 2 2
I should not be able to add another row 'x5' and have the values for A and B be 1,1 as they are already in the database in x1?
Ok we managed to get it to work and thanks to OMG. Go to the t...
I am creating a stored procedure that produces reports based on data in a SQL database and stores these reports in a separate database. The data being reported is the total time over a date range that a motor was running. I want to be able to detect if the timeframe I am reporting overlaps previous reports based on date times.
For ins...
I'm a Django newbie and I wonder if there is a more efficient way (at a database level) of doing the following.
I have the model:
class Foo(models.Model):
item=models.IntegerField()
another_item=models.IntegerField()
And want to get an iterable of all the distinct values of "item".
This is what I have so far:
distinct=set([...