Click here to Skip to main content
15,885,936 members

Comments by TenmanS14 (Top 14 by date)

TenmanS14 13-May-16 5:27am View    
by the look of that you just need to be creating 3 tables to import into,

applicant which will hold applicantid and other stuff if you have it
school which will hold schoolid and name and other stuff

and a 3rd table to join them which will hold applicantid and schoolid.

to import from that CSV I'd import it into a temp table and then run through that with a counter to add records to the other tables.
TenmanS14 25-Jan-16 6:41am View    
maybe look at SQLite...

https://www.sqlite.org/about.html

SQLite is an embedded SQL database engine. Unlike most other SQL databases, SQLite does not have a separate server process. SQLite reads and writes directly to ordinary disk files. A complete SQL database with multiple tables, indices, triggers, and views, is contained in a single disk file.
TenmanS14 18-Jan-16 11:29am View    
at a guess you want to create a stored procedure...

https://msdn.microsoft.com/en-GB/library/ms345415.aspx
TenmanS14 18-Jan-16 6:41am View    
LOL, apologies for that, had been in the pub for lunch before I wrote it... on the right lines though I think, I suspect you could achieve what you want with a self join..
TenmanS14 15-Jan-16 11:48am View    
is there a value which will be common between them and unique for each final record, rather than them just being 2 different weeks of data? i.e. could you only have one memberno per week or one of each unit per week?

INSERT INTO #temp1 (MemberNo, MemberItemCode, NCDescription, Week1Usage, Week1Price, week2Usage, week2Price)
select InvD1.MEMBERNO, InvD1.ITEMCODE, InvD1.DESCRIPTION, InvD1.QTYSHIPPED, InvD1.PRICE, InvD2.qtyshipped, InvD2.price
FROM INVOICEDETAIL as InvD1
join INVOICEDETAIL as InvD2 on InvD1.unit = InvD2.unit
WHERE InvD1.UNIT=@Unit
AND (INVOICEDATE BETWEEN @BegDate AND @Week1End)