|
Hi All
I want to calculate the total of some monatry amounts within a table
i can do this by the following
declare @cost1 money
select @cost1 =sum(cost)from mydb..amounts
sometimes though there maybe no records in the amounts table, and the above statement would then return NULL
instead of NULL i would like it to return 0
i would like to do something like
select @cost1 =sum(cost) 0 as null from mydb..amounts
but this doesnt work
does anyone have any ideas ??
Thanks
Si
|
|
|
|
|
select sum(nvl(cost,0) total_cost from mydb..amounts;
Chris Meech
I am Canadian. [heard in a local bar]
Nobody likes jerks. [espeir]
|
|
|
|
|
Chris Meech wrote: select sum(nvl(cost,0) total_cost from mydb..amounts;
thanks, but this doesnt work
whats nvl ??
|
|
|
|
|
SELECT @cost1 = ISNULL(SUM(cost), 0) FROM mydb..amounts
|
|
|
|
|
My current procedure returns XML but sans any kind of "root" tag... is there a simple clause to get it to wrap the returned values in a root element ?
Thanks
|
|
|
|
|
Hi there,
Im looking for a method to do bulk insert into SQL Server 2005 from a Generic List<t> and if its possible!?!
In .NET 2.0 is SqlBulkCopy useful and maybe we can use it!?! But we have do a extra step.
The flow:
DataSource > SqlBulkCopy > DataSource
List<> IDataReader dbo.myTable
Examplecode:
<br />
SqlConnection c = new SqlConnection("xxx"));<br />
SqlBulkCopy bc = new SqlBulkCopy(c);<br />
<br />
bc.DestinationTableName = "dbo.myTable";<br />
<br />
c.Open();<br />
<br />
myItem mi;<br />
List<myItem> myList = new List<myItem>();<br />
<br />
for (int i = 0; i < 10; i++)<br />
{<br />
mi = new myItem();<br />
mi.Text = "a" + i.ToString(); <br />
myList.Add(e);<br />
}<br />
<br />
IDataReader r = myList.????<br />
<br />
bc.WriteToServer(r);<br />
...<br />
Do you have any idea?
Regards
//Albin
|
|
|
|
|
I'm having trouble using two seperate BindingContext's on the same form.
The form contains two group boxes, each containing a TextBox. The TextBoxes are bound to the same field of the same BindingSource. Each group box has it's own BindingContext:
void BindControls()
{
groupBox1.BindingContext = new BindingContext();
groupBox2.BindingContext = new BindingContext();
textBox1.DataBindings.Add("Text", projectsBindingSource, "prDescription");
textBox2.DataBindings.Add("Text", projectsBindingSource, "prDescription");
}
projectsBindingSource is of type BindingSource!
Now I would expect that I could scroll the context in one group box independantly of the other. However, when I execute the following code:
BindingManagerBase projectsBinding;
projectsBinding = groupBox1.BindingContext[projectsBindingSource];
projectsBinding.Position++;
Both groupBox1 and groupBox2 scroll to the next record.
Ant idea's
Regards,
Kees Vermeulen
|
|
|
|
|
i need to store wav files into my database and reterive it again
how to do that
ma_refay
|
|
|
|
|
Use an image column - it can store up to 2Gb of any binary data you choose.
|
|
|
|
|
I am somewhat at a lost right now and would like some guidence. I have a SqlDataAdapterthat I want it to use a stored procedure. The stored procedure has 4 parameters. Here is the code passing the values:
sqlDataAdapter1.SelectCommand.Parameters.Add("@BNAME",SqlDbType.Char).Value = strBname;
sqlDataAdapter1.SelectCommand.Parameters.Add("@ENAME",SqlDbType.Char).Value = strEname;
sqlDataAdapter1.SelectCommand.Parameters.Add("@BZIP",SqlDbType.Int).Value = intBzip;
sqlDataAdapter1.SelectCommand.Parameters.Add("@EZIP",SqlDbType.Int).Value = intEzip;
When I run the code I get a sql error stating
this
Here is my stored procedure:
ALTER PROCEDURE dbo.SelectActive
(
@BNAME char,
@ENAME char,
@BZIP int,
@EZIP int
)
AS
SELECT CustName, CustAdd, CustCity, CustState, CustZip
FROM CustomerList
WHERE (CustType = 1 OR CustType = 6) AND (ASCII(CustName) >= ASCII(@BNAME)
AND ASCII(CustName) <= ASCII(@ENAME)) AND (CustZip >= @BZIP) AND
(CustZip <= @EZIP )
ORDER BY CustName
RETURN
When I was configuring the data adapter, I came across this page. I am a little comfused on what to do here. I can select which data column on the right, but can't do anything with it. As you can see from the procedure, 2 data rows are affected. What to do?
Thanx in advance!
Jude
|
|
|
|
|
I'm not sure what is going on here but it seems to me that you are looking for a CREATE PROCEDURE rather than 'ALTER'.
Steve
|
|
|
|
|
Hi,
I have put some free useful info on :
http://www.vkinfotek.com/data.html and
http://www.vkinfotek.com/object.html
If you need any additional specific info kindly email me or post here.
Regards
Bhar
|
|
|
|
|
We have a number of built scripts in VS2003 database projects and we utilize the Create Command File... command which creates a self-contained cmd file for running the scripts. We push this to our ops people for managing elevations of data/databases/code to production.
Visual Studio 2005 does not appear to have the Create Command File option in it anymore. But usually ( emphasize usually ) MS has an alternative somewhere. Is there an alternative or equivalent for creating the cmd file for a Database Project, and how do I use it???
We do not want our ops people to be selecting scripts and clicking Run since there is always the chance they can miss a script and impact a production deployment.
Thanks,
-- modified at 12:03 Tuesday 8th August, 2006
|
|
|
|
|
Hi,
I need to do a "select distinct emp_type from dtName" on a datatable in vb.net. in order to get a list of distinct employee types from a datatable in code. I can't work on DB side, caue i'm getting data from text file, and looping through every record is hideous!
Regards,
Tintin
|
|
|
|
|
Issue SQLcommand.Text = "select distinct emp_type from dtName" in your VB code.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
i need to make table that have sounds i need to select sounds from this table to play in background automic in background when the form load and how i stop sound playing
ma_refay
|
|
|
|
|
You can use the TSQL SOUNDEX to evaluate if two string have the same sound.
<br />
SELECT SOUNDEX ('Smith'), SOUNDEX ('Smythe');<br />
<br />
----- ----- <br />
S530 S530 <br />
<br />
(1 row(s) affected)<br />
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Sorry the above does not answer you question.
Store sounds as binary data blobs as you would with Images. Search for storing an image in a db and use similar code.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
ma_refay wrote: how i stop sound playing
It would help if you gave us some clues, such as what programming language you're using...
Steve S
Developer for hire
|
|
|
|
|
How can i get the date of the day of the system
when i used this statement in the sql biulder of the dataenvironment of vb6
the sql analysis tell me that the error in the date
select * from emp
where hidate=Date();
i use it with () and without it and the problem still please
help
|
|
|
|
|
Your question is not clear. Do you want to get the system date?
if so then you can use getdate() for that purpose.
Best Regards,
Apurva Kaushal
|
|
|
|
|
LEARN_FOR_EVER wrote: help help help help h e l p
This is a useless subject line. Everyone posting a new thread here is looking for help in some form or another. Your subject line should be a brief description of the problem. e.g. "Date in SQL Server"
|
|
|
|
|
LEARN_FOR_EVER wrote: How can i get the date of the day of the system
GETDATE() returns the current date/time.
The rest of your question is not particularly clear. What do you want to do?
|
|
|
|
|
In stored procedure i used a query
"select Password from tblUser where username='User1' and password='Password'
the reselt is 'Password'
But at the backend the value of Password is 'password'
(that is small letters.
Since password validation needs case sensitive validation how am i supposed to used string comparator. Else is there any other option
ItsMe
|
|
|
|
|
If you are using SQL 2005, you can use HashBytes function to calculate a hashing value of password then compare two hashing values.
If you use SQL 2000, you can use BINARY_CHECKSUM function instead of.
|
|
|
|