|
Amharic is supported by Unicode, so if your column type is nvarchar and you use unicode all the way (string in .Net is Unicode) there should be no problem.
|
|
|
|
|
Good day all!
Please assist if you can in resolving this my SQL query difficulty.
I have 2 query results as follows;
Table A
CID | NAME | CREDENTIAL | BAL | GID1 | GID2 | UNIQUE_ID
01 | AAA | debtor | 20 | 03 | 02 | 01-03,02
02 | BBB | debtor | 15 | 01 | 05 | 02-01,05
03 | CCC | debtor | 10 | 02 | 04 | 03-02,04
TABLE B
CID | NAME | BAL
01 | AAA | 20
02 | BBB | 15
03 | CCC | 10
04 | DDD | 5
05 | EEE | 2
06 | FFF | 4
Now I need help in getting TABLE C that should look like this;
CID | NAME | CREDENTIAL | BAL | UNIQUE_ID
01 | AAA | debtor | 20 | 01-03,02
03 | CCC | guarantor | 10 | 01-03,02
02 | BBB | guarantor | 15 | 01-03,02
02 | BBB | debtor | 15 | 02-01,05
01 | AAA | guarantor | 20 | 02-01,05
05 | EEE | guarantor | 2 | 02-01,05
03 | CCC | debtor | 10 | 03-02,04
02 | BBB | guarantor | 15 | 03-02,04
04 | DDD | guarantor | 5 | 03-02,04
WHAT I INTEND TO ACHIEVE
This is like a loan collection summary.
CID = General Primary Key for every customer
NAME = Customer names
CREDENTIAL = To help me diffentiate between the loan collector and the guarantors, so that I can group in my front end VB application.
BAL = everyone account balance
GID = guarantor for the loan collector, GID is a subset of CID
UNIQUE_ID = A string to combine the CID and the GID for a loan transaction so that I can easily isolate everything about a single loan transaction.
Table A is an abridged form of each loan collection transaction.
Table B carries the account balance for every customer.
Now, I expect Table C to carry all loan record in Table A and use the entries in GID1 and GID2 columns to fetch their corresponding details from Table B while retaining the Unique_ID entries from Table A so that sorting by Unique_ID will bring all loans together.
Please assist me with a way to achieve this, I have been thinking for days, yet no breakthrough.
Thanks in advance
modified 28-Jan-19 21:07pm.
|
|
|
|
|
|
Thanks Richard for your response. Indeed, I have taken a look at the link suggestion. The 2 result sets I have above was achieved using 'Joins'. But achieving 'Table C' is the challenge as I currently can't figure a way out of it.
|
|
|
|
|
It would help is you would explain how to get Table C. It is not obvious to me just by looking at the data.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Thanks
I have edited my original post to carry a better explanation on what I want.
|
|
|
|
|
Given that we have no information about your source database tables it is not something that we can do for you.
|
|
|
|
|
Thanks,
I have edited my original post to add an explanation about the entire process I intend to achieve.
Table A and Table B is a result of SQL query combining multiple database tables. So I intend to retrieve Table C from the result of Table A and Table B
|
|
|
|
|
What is not obvious is whether Table A has entries for "Gaurantor" and if there are a max of 2 records for each CID in Table A
Assuming Table B has a single entry for each CID
Select *
from TableB
inner join TableB B and TableA A on A.CID = B.CID
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
CID in Table A is always single entry as a customer can't have two running loans as same time and in Table B CID is still single entry as is the account balance of all customers. But Table A.CID is always a subset of Table B.CID.
"guarantor" entries under CREDENTIAL column in Table C is just a string input ( like select 'guarantor' as CREDENTIAL) or (isnull(CREDENTIAL, 'guarantor')) to make me identify that entry as details of a particular guarantor while UNIQUE_ID entries in Table C helps groups individual loan together as both the loan collector and guarantors will have same entries.
CID in Table C can have multiple same values but all entries must be drawn from the primary column Table B.CID
|
|
|
|
|
Ok that is very straight forward, pick your primary table A or B as they have a single value for the CID. Use inner joins from A to B and A to C and select the fields you need to display.
If there are missing records in your secondary tables then use left outer joins.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I tried all I could, but still failed to see anyway to directly generate Table C from Table A and B.
I have to generate a new Table D (which looks like Table C - Table A) from my based database tables. Using Table A Union Table D now gives me Table C.
Thanks a lot for your support.
|
|
|
|
|
My bad, I thought table C existed with CID and Credential.
Where do you expect to get the credential for Guarantor from it is not in table A or B in your examples.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
"guarantor" entries under CREDENTIAL column in Table C is just a string input ( like select 'guarantor' as CREDENTIAL) or (isnull(CREDENTIAL, 'guarantor')) to make me identify that entry as details of a particular guarantor.
Since I have gotten a work around for this particular challenge, how do I mark my question as 'Closed' or 'Answered'?
|
|
|
|
|
paul4everyone wrote: how do I mark my question as 'Closed' or 'Answered'? You don't. Generally if you work it out it is nice to post the solution.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Hello !
I have a sql server database that I use with entity framework.
The database have 2 tables :
Customers : ID , Name , city
Orders : ID , sender , receiver
Both sender and receiver are Customers. So I should have 2 relationship for orders with the same table Customers.
Is it safe to use this with sql server and entity framework ?
|
|
|
|
|
Yes but your table design sucks try.
Customer
CustomerID
Name
City
Order
OrderID
CustomerID
Sender
Receiver
This assumes that the customer only ever lives in 1 city and never moves.
Take a look at some of these database structures and see if one will work for you.
http://www.databaseanswers.org/data_models/[^]
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
At least look for an example before asking the question.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi
when I execute the code in 2012 SQL Server we are getting following error:
Could not find stored procedure 'sp_set_session_context'. Automation Exception: Could not find stored procedure 'sp_set_session_context'
We tested in 2016 server it is working fine but when we moved to 2012 this is failing. when I searched online I come to know that 'sp_set_session_context' it is new future introduced in 2016, I need relevant commands to implement same in 2012 server..
|
|
|
|
|
GaneshVidiyala wrote: I need relevant commands to implement same in 2012 server..
The stored procedure itself uses something that doesn't exist in the older version. So that isn't going to help you.
You are not going to easily replace that.
1. It is just a name/value store HOWEVER it is tied to the transaction.
2. So each transaction you would need to 'create' a corresponding store
3. For each transaction you would need to destroy the corresponding store. If you fail to do this you will eventually have a data problem.
4. Then you can use the store, maybe.
I suspect it is easier to just re-write the functionality. I suspect someone just used it so they wouldn't need to pass data around. So pass the data. And/or untie it from the transaction - just tie it to the processes that use it.
|
|
|
|
|
Hi all
I installed ssrs 2013 and made a report and deploy it inro ssrs server,my source database which I used is oracle and I also have oracle client and .net data providet in the same server that ssrs in installed,
When I want to view published reports on the server the following error is rasied:
An error has occurred during report processing. (rsProcessingAborted)
An attempt has been made to use a data extension 'ORACLE' that is either not registered for this report server or is not supported in this edition of Reporting Services. (rsDataExtensionNotFound)
could anybody help me out of this?
|
|
|
|
|
more than likely your Oracle hosts file is messed up on the server where the oracle client is installed. Check out your tnsnames.ora file and the path variable to make sure it is included in there. Hopefully you already have this resolved before this message.
To err is human to really mess up you need a computer
|
|
|
|
|
The following short Python program is supposed to read data from a SQLite datatable, convert some very large integer values in one field to Doubles, and write the data to an appropriately configured Access Table.
It runs happily with no error, but no data appears in the Access Table. What am I missing?
import sqlite3
import pyodbc
conn1 = sqlite3.connect('data.db')
cur1 = conn1.cursor()
conn2 = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=G:\My_Data_Folder\NewEnergy.accdb;')
cur2 = conn2.cursor()
data=cur2.execute('SELECT * FROM RawValues')
print (cur2.fetchall())
data=cur1.execute('SELECT * FROM RTPValues ORDER BY TimeSerial ASC')
rows=cur1.fetchall()
for row in rows:
cur2.execute('INSERT INTO RawValues (Millitime, PowerCost) VALUES (?,?)',(float(row[0]),row[1]))
conn2.commit
conn2.close
conn1.close
[EDIT]The error, as pointed out by Richard MacCutchan at the end of the thread, is that the conn2.commit call (as well as the subsequent .close calls) are not function calls at all, because they are missing the terminal empty parentheses that are required for Python to treat them as such. The last three lines of the code should be:
conn2.commit()
conn2.close()
conn1.close() As it stands, the program does what it is supposed to do, but the data is never written to the file.[/EDIT]
modified 8-Dec-18 14:51pm.
|
|
|
|
|
The float built-in only takes a single parameter, you are passing two, so that code will fail. Also you have specified two values in your insert statement but you are trying to pass only one.Victor pointed out my mistake.
[edit]
Having looked at the documentation, I guess that the extra parentheses round your values may be the problem. The example is:
cursor.execute("insert into products(id, name) values (?, ?)", 'pyodbc', 'awesome library')
So perhaps your code should be:
cur2.execute('INSERT INTO RawValues (Millitime, PowerCost) VALUES (?,?)', float(row[0]), row[1])
[/edit]
modified 6-Dec-18 7:54am.
|
|
|
|
|
Richard MacCutchan wrote: The float built-in only takes a single parameter, you are passing two, so that code will fail. Also you have specified two values in your insert statement but you are trying to pass only one.
Hmmm...
It seems to me there are two values here:
Quote:
cur2.execute('INSERT INTO RawValues (Millitime, PowerCost) VALUES (?,?)',(float(row[0]),row[1]))
The first is Quote: float(row[0]) , the second - Quote: row[1]
|
|
|
|