OK, I have a complicated query from a poorly designed DB... In one query I need to get a count from one database, information from another with a link from another, here goes:
Each blog has a type (news, report etc) and a section Id for a certain part of the site but it also can be linked to multiple computer games and sections)
type (...
I have a storeprocedure:
CREATE PROCEDURE [dbo].[BrandDrugDetailsInsert]
@BrandDrugDetailsID uniqueidentifier OUTPUT,
@BrandDrugID uniqueidentifier
AS
BEGIN
INSERT INTO Pharmacy_BrandDrugDetails(BrandDrugID) OUTPUT INSERTED.BrandDrugDetailsID
VALUES (@BrandDrugID)
END
Anytime i try to retieve the value "@BrandDrugDetai...
I want to try to update a postgresql table with it's own values.
This table contains an overview of the products sold by year and month.
CREATE TABLE sales
(
sector character(3),
brand character(4),
product character(16),
syear integer,
smonth integer,
units_sold integer,
units_sold_year integer,
CONSTRAINT pk_sales_id ...
Hi.
Currently I'm making sort of SQL command line interface for web-based application. It should act roughly like sqlPlus.
I have encountered a problem how to execute sql's. They can be both as SQL and/or PL/SQL.
First way I thought that I can split them (by ';' or ';/') and detect separately if it's sql select or delete/update/insert ...
Is Commit a DML instruction in PL\SQL?
...
I have this table:
Strawberries 2
Strawberries 3
Strawberries 4
Chocolate 3
Chocolate 4
Chocolate 5
Chocolate 6
Apples 3
Apples 4
Apples 5
Apples 6
My idea is to get the number of items, and the total of items per thing, like so:
Item Number Total
Strawberries 2 9
Strawberries 3 9
Strawberries 4...
I have the following query:
SELECT FROM tblMailToSend
WHERE (DateToSend < @dateToSend OR DateToSend IS NULL) AND DateSent IS NULL
@dateToSend is passed in as a param
I'm trying to convert this to linq to sql query.
I've got:
db.MailToSend.Where(m => m.DateToSend == null || m.DateToSend <= dateToSend)
.Where(m =>...
When I use a column alias in a query with find_by_sql, it doesn't appear to be set in the result objects, even when I add an attr_accessor for the property.
class Country < ActiveRecord::Base
attr_accessor :average_score
def self.sorted_by_average_score
sql = "SELECT country_id, AVG(score) AS average_score, countries.name " +
...
New to VB.Net,
How to insert or select the dataset value.
cmd = New SqlCommand("Select * from table1", con)
ada = New SqlDataAdapter(cmd)
ds = New DataSet
ada.Fill(ds)
cmd = New SqlCommand("Select * from '" & ds.Tables(0) & "' ", con)
mydatatable1.Load(dr3)
It was showing the error in '" & ds.Tables(0) & "',...
I'm trying to get the new rating from an UPDATE statement in java
int userID = 99;
String sql = "UPDATE table SET rating=rating+1 WHERE user_REF="+userID;
statement.executeUpdate(sql);
I can just do another SELECT statement, but isn't there a better way to retrieve the value or row while updating?
...
I am trying to round to 3 decimal places from two variables of type money in SQL Server 2008.
DECLARE @Val1 money = 554.5344
DECLARE @Val2 money = 84020.37
DECLARE @Result decimal(6,5) = @Val1/@Val2 *100
SELECT @Result
The result above is 0.65. With a calculator it is 0.65999995001212, I need the result to be 0.659.
...
I'm frustrated... my site has suddenly become very unstable. So much so that hitting refresh over and over will cause it to crash. To investigate, I turned off all error handling so I could see some YSOD's.
Instead of trying to write it all out, I made a video showing the issue. You can see it here on YouTube.
Here's a copy of the stac...
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["idc"], $_GET["qty"]);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET["idc"], $_GET["qty"]);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET["idc"], $_GET["id"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
function AddItem($itemId, $qty){
$result...
I am developing some Python modules that use a mysql database to insert some data and produce various types of report. I'm doing test driven development and so far I run:
some CREATE / UPDATE / DELETE tests against a temporary database that is thrown away at the end of each test case, and
some report generation tests doing exclusively...
Hi
I m selecting data from two different tables with no matching columns using this sql query
select * from (SELECT s.shout_id, s.user_id, s.time FROM shouts s
union all
select v.post_id, v.sender_user_id, v.time from void_post v)
as derived_table order by time desc;
Now is there any other way or with this sql statement ...
how would you get the 5 value from a row of data.
...
There is quite often situation when you need to execute INSERT, UPDATE or DELETE statement based on some condition. And my question is whether the affect on the performance of the query add IF EXISTS before the command.
Example
IF EXISTS(SELECT 1 FROM Contacs WHERE [Type] = 1)
UPDATE Contacs SET [Deleted] = 1 WHERE [Type] = 1
Wha...
What would be the best method to use for testing that connection managers are correctly pulling their connection strings from the package configurations on multiple packages (In VS 2008). In the past I have created a data flow which ran the query select @@servername and outputed to a text file. While this works, it seems a bit redundan...
I expected either index to be used for my SELECT DISTINCT query below:
CREATE TABLE test(
value TEXT
);
INSERT INTO test (value) VALUES ('a');
INSERT INTO test (value) VALUES ('b');
INSERT INTO test (value) VALUES ('c');
CREATE INDEX value_i ON test(value(32));
CREATE FULLTEXT INDEX value_i_ft ON test(value);
SELECT DISTINCT value ...
I have three tables like this (simplified version):
Object
---------------
ID | ObjectName
---------------
Category
-----------------
ID | CategoryCode
-----------------
ObjectCategory
---------------------
ObjectID | CategoryID
---------------------
How can I select ObjectName and CategoryCode for all objects who don't belong to ce...