ADO SQL Inquiry

S

Sam

I wonder how do I store these records into SQL Server table of the following
SQL Statement?

SQL Statement
==========
select stocknumber,sum(qty) as qty,sum(weight) as weight
from inventoryledger
where julian_date <= 101001
group by stocknumber
order by stocknumber


Result
====
Stocknum Qty Weight
-------- --------- ----------
010010 2628.00 31536.0000
010013 .00
010020 1232.00 14784.0000
010034 919.83 16557.0000

Please advise.

Many thanks.
 
W

W.G. Ryan eMVP

Sam, What specifically are you asking? Those records are already in the
database right?

Assuming that the schema of the new table mached the below query, you'd just
user an Insert Statement with a subquery that was the same as your select
statement

INSERT INTO SomeTable(Stocknum,
Qty,
Weight)
VALUES(select stocknumber,sum(qty) as qty,sum(weight) as weight
from inventoryledger
where julian_date <= 101001
group by stocknumber
order by stocknumber
)

If you're asking about how to get those values into a ADO.NET datatable,
then you'd just use a DataAdapter and set that select statement to it's
SelectCommadn.. Or you could not use aggregation server side and use
DataTable.Compute to pull the aggregates.

If you could tell me specifically what you were looking to do I could
probably be of more help.

Cheers,

Bill
 
S

Sam

Thanks for advise and guideline.

Yes, I want to insert record based on my SQL statement and given example is
very helpful for my software development.

Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top