I have a number of type Decimal(8, 2) and have been using Substring to get fractional value.
E.g.)
declare @val decimal(8, 2), @strVal varchar(10)
set @val = 15.80
set @strVal = cast(@val as varchar)
select @val, substring(@strVal, charindex('.', @strVal), len(@strVal))
Is there a better way to simply get fractional value, .80 fro...
I want to count some rows in my database and I'm using the following code:
$tagname = Person;
$query = "SELECT COUNT(thread_tag_map.tag_id) AS tagcount
FROM tags, thread_tag_map
WHERE thread_tag_map.tag_id = tags.id
AND tags.name = '$...
As part of a release we run a load of PL/SQL scripts against a database. Recently someone left the ; off the end of a line in one script that was called another script so this meant that script did not get run. Because this did not cause an error, it just didn't get run, it took quite a while to track down what had happened.
I want to c...
Hi. I've got a problem here with a join and pagination. I have 3 Models:
Pad
Tag
TagRelation
I use Tag relation to manage a ManyToMany relationship betweent Pads and Tags (with the through attribute of te ManyToMany field).
Now when i do a join on the Pad and Tag tables it gives me something like this...
pad.name tag.name etc
...
I am trying to see what is the best way to handle the following scenario
I have a table called, lets say User, and i have a table called items. Each user can have multiple items added to his account. I have another table , lets say AssociateItem, which maintains the association between user and the items. (links UserID to ItemID). A us...
I have a simple SQL query,
SELECT * FROM phones WHERE manu='$manuf' AND price BETWEEN $min AND $max
The issue is that all of the variable fields are connected to fields that will sometimes be empty, and thus I need a way to make them match any value that their respective field could take if they are empty. I tried
$min=$_REQUEST['min...
Hi,
I have a SP using FTS (Full Text Search). I want searches across multiple fields, 'intelligently' ranking results based on the weights I assign.
Consider a search on a view fetching data from tables: Book, Author and Genre.
Now, I want the searcher to be able to do: "Ludlum Fiction", "Robert Ludlum Bourne", "Bourne Ludlum", etc....
public static bool TruncateTable(string dbAlias, string tableName)
{
string sqlStatement = string.Format("TRUNCATE TABLE {0}", tableName);
return ExecuteNonQuery(dbAlias, sqlStatement) > 0;
}
...
Hi,
I run a site at localhost and i would like to see which queries are executed.
I've seen that some pages execute a lot of queries (eg 107) and i would like to see which are all these,as i think they're a lot..
(i know how many queries are executed, as the queries are executed through a function which also stores at a global value the...
In Access 2003, I'm trying to take a table and if any Indicator = 1 for ANY line of a given ID, make all lines = 1 for that ID
For Example, if we have:
ID Indicator
Jack 0
Jack 0
Jeff 1
Jeff 0
Mark 1
Mark 1
Would become:
ID Indicator
Jack 0
Jack 0
Jeff 1
Jeff 1
Mark 1
Mark 1
Since both Jeff and Mark have at least 1 line with...
Hello,
I have code snippet in my PL/SQL procedure that does the following:
INSERT INTO payment_operations (id, subscriber, amount, description) VALUES (payment_id, 1234, 5, 'Test');
COMMIT;
SELECT subscriber INTO test_subscriber FROM payment_operations_view WHERE id = payment_id;
After this I get an exception "no_data_found"! Howeve...
I have the following table in an Oracle database:
InvoiceNumber InvoiceDate InvoiceCorrelative
------------- ----------- ------------------
123 02-03-2009 0
124 02-03-2009 0
125 02-04-2009 0
126 02-04-2009 0
127 02-...
I have two select statements joined by "union". While executing that statement I've got:
Error report:
SQL Error: ORA-01790: expression must have same datatype as corresponding expression
01790. 00000 - "expression must have same datatype as corresponding expression"
Maybe you can give me an advise on how to diagnose this problem?
...
The requirement is to copy rows from Table B into Table A. Only rows with an id that doesn't already exist, need to be copied over:
INSERT INTO A(id, x, y)
SELECT id, x, y
FROM B b
WHERE b.id IS NOT IN (SELECT id FROM A WHERE x='t');
^^^^^^^^^^^
Now, I was trying to write this with an outer join ...
Is it best to communicate between two scrabble boards on separate computers by creating a cloud with a SQL table, simulating the board. And every time I move is made you contact the server and update the local board?
...
trying to run the following statement in sql mgmt studio
declare @rick as decimal(13,3)
@rick = -.5
select bob = abs(@rick)
any ideas why this won't work?
...
Here's a simplified example of what I'm talking about:
Table: students exam_results
_____________ ____________________________________
| id | name | | id | student_id | score | date |
|----+------| |----+------------+-------+--------|
| 1 | Jim | | 1 | 1 | 73 | 8/1/09 |
| 2 | Joe | ...
Is there a way to retrieve all the keys of the newly inserted records when using an INSERT INTO ... SELECT FROM query?
...
If I join table A to table B like this...
select A.* from A
left outer join B on A.Id = B.aId and @param = 'someValue'
and @param does not equal 'someValue', does SQL Server even attempt to match records from table B or is it smart enough to know the condition will never be true?
...