I am implementing a bitwise filter using SQL, and I want to see if the following optimization is always valid in all cases, and I'm not sure how to prove it.
My goal is to limit the number of rows that get compared.
Standard filter pseudo-sql:
IF (A & B = A) // SHOW VALUE
The question is, will it work to add this? :
IF (A = B) OR (A...
I'm roughly 10% into my website project and I'm trying to figure out what sort of load I'm putting on the database. When a user is logged in, I have many functions that trigger every minute, and every time someone visits the page, a number of elements, such as area code lists, states and countries are pulled to build a registration page...
I need to generate a report from a table with the structure and data as given below.
Table Ticket has data as given below.
ID Assigned_To
100 raju
101 raju
102 raju
103 anil
104 anil
105 sam
106 raju
107 raju
108 anil
The Oracle SELECT should generate the below report
Fro...
Switching to SQL 2008 we are using table variables now as parameters for stored procedures. While it's not a problem to use them in .NET, we have some old code in Delphi where we want to switch to these new procedures as well.
The problem we cannot find how to set parameters for TADOCommand to table value.
...
In SQL, I've got a table that maps token=>count; it's a dict where the default value is 0. If I want to increment a token, I can say:
insert into my_table (token, count)
values (my_token, 1)
on duplicate key update count = count + 1;
and if a token doesn't exist yet, it's inserted with count=1. Nifty.
Is there a similarly easy way ...
I have a sql server nvarchar field with a "Default Value or Binding" of empty string. It also happens to be a not null field.
Does this mean that there is no default or that it is a default of a string with no characters in it.
If I don't insert a value, will it insert with an empty string or fail with a "not null" error?
...
I'm trying to get the count of documents within 4 specific sections using the following code:
SELECT
category.id
, category.title
, count(ts1.section_id) AS doc1
, count(ts2.section_id) AS doc2
, count(ts3.section_id) AS doc3
, count(ts4.section_id) AS doc4
FROM
category
LEFT JOIN category_link_section A...
I have a data set consisting of time-stamped values, and absolute (meter) values. Sometimes the meter values reset to zero, which means I have to iterate through and calculate a delta one-by-one, and then add it up to get the total for a given period.
For example:
Timestamp Value
2009-01-01 100
2009-01-02 105
2009-01-03 ...
Very simple question but all the answer I read over the web doesn't apply.
I try to do an update on a ASP.NET Gridview but when I click on update, I get this error:
Incorrect Syntax near 'nvarchar'. The scalar variable @intID must be declare.
Here is my datasource. I guess the problem come from here but I can't see where...
<asp:SqlD...
I have a table defined by:
create table apple(
A number,
B number);
Now, I need to get values in the table such as the following:
A B
------------------
1 4(max of A)
2 4(max of A)
3 4(max of A)
4 4(max of A)
How can I insert these rows, making B the maximum value of A?
...
Let's say that I have an article on a website, and I want to track the number of views to the article. In the Articles table, there's the PK ID - int, Name - nvarchar(50), and ViewCount - int. Every time the the page is viewed, I increment the ViewCount field. I'm worried about collisions when updating the field. I can run it in a sp...
I have this query:
SELECT g.title, g.asin, g.platform_id, r.rank
FROM games g
INNER JOIN ranks r ON ( g.id = r.game_id )
ORDER BY r.rank DESC
LIMIT 5`
Now, this is my JOIN using Zend_Db_Select but it gives me array error
$query = $this->select();
$query->from(array('g' => 'games'), array());
$query->j...
In an attempt to make the best index choices for my database, I've noticed some particular behaviour which I'd like to address.
Observe the following table and corresponding index (SQL Server 2005):
CREATE TABLE demo
(
id INT PRIMARY KEY IDENTITY,
name NVARCHAR(50) NOT NULL,
password BINARY(20) NOT NULL
);
CREATE NONCLUSTERED INDEX...
Hi friends,
I has a button when the user clicks it then it must go to specified URL
But i have to create my URL out of the values coming from database and most important is i need to modify the values coming from database before i make a URL out of it
Suppose the values from database is
country- Franc...
I am storing first name and last name with up to 30 characters each. Which is better varchar or nvarchar.
I have read that nvarchar takes up twice as much space compared to varchar and that nvarchar is used for internationalization.
So what do you suggest should I use: nvarchar or varchar ?
Also please let me know about the performa...
There is a table with Columns as below:
Id : long autoincrement;
timestamp:long;
price:long
Timestamp is given as a unix_time in ms.
Question: what is the average time difference between the records ?
...
There are two tables 1 and 2 with columns
Id: unique ; timestamp:long; money:double
SOME RECORDS are missing in Table 1 and table2.
Question: try to merge both tables together with the timestamps of table1 , and if the records is only in table 2 adjust the timestamp with average time difference between table 1 and table2.
Please help ...
I have an application where a user performs an action and receives points. Would it be a better idea to perform the arithmetic in the application and update the points database field with the resulting value, or have the database do the math?
Assuming a user with 0 points is to receive 2 additional:
//app does the math (0+2) and issues...
I am using a clr procedure in one of my normal stored procs and i'm experiencing an odd error handling situation. Check the following code, it works as expected...
BEGIN TRY
create table #test(id varchar(2))
insert #test
select '123'
select * from #test
END TRY
BEGIN CATCH
select 'an error occured but was handled'
END CATCH
Ho...
Hello,
Say I have a simple table that has the following fields:
ID: int, autoincremental (identity), primary key
Name: varchar(50), unique, has unique index
Tag: int
I never use the ID field for lookup, because my application is always based on working with the Name field.
I need to change the Tag value from time to time. I'm usin...