Showing posts with label newbie. Show all posts
Showing posts with label newbie. Show all posts

Tuesday, March 20, 2012

Comparing 2 different databases [NEWBIE]

Hello-

I am trying to audit values between 2 different databases.

ie: We send out dividend checks every year, and it is based on how much
our customers spend with us. Therefore, once a year we allocate our
profits to the customers by dumping customer information from the
billing database to the accounting database. Now the check gets issued
from the accounting database after that and the 1099 capital gains gets
issued after the check. The time that elapses between the checks and
1099's is the problem, because people move, they change their names etc.
etc. What I want to do is audit the accounting data against the current
billing data. The records have a common account number to join, but I
don't know how to form a select (or whatever query it may be) accross
databases. I've only worked the select from within a single database.

I would appreciate some help, I am very new to SQL and my experience is
limited to the SELECT statement. However, I am willing and determined
to learn new and different things. :)

Thanks in advance,

BenA guess at what you may need...

SELECT
A.CustomerId,
A.CustomerName,
A.CustomerAddress,
B.CustomerName,
B.CustomerAddress,
A.Dividend

FROM
MyServer.FirstDatabase.dbo.FirstList A
LEFT JOIN MyServer.SecondDatabase.dbo.SecondList B
ON A.CustomerId = B.CustomerId

WHERE
A.Dividend <> 0.00 AND
A.Deceased = 0

ORDER BY
A.CustomerName,
B.CustomerName,
A.CustomerAddress,
B.CustomerAddress

I've deliberately left the fields as something obvious (in case anyone
asks about naming standards etc) so that you can see what basic work
you would need to do. Please note, I've used aliases against the table
names as it's always good to do this for ease of reading. I've assumed
that you want everything from the first list (A) and only the records
from the second list (B) - hence the left join.

I've also added a 'Deceased' clause so you can see how to add
additional statements in the WHERE part of the statment. Obviously you
will need to substitute the various fields and databases for your own.

Hope that helps

Ryan

Ben Wehrspann wrote:
> Hello-
> I am trying to audit values between 2 different databases.
> ie: We send out dividend checks every year, and it is based on how
much
> our customers spend with us. Therefore, once a year we allocate our
> profits to the customers by dumping customer information from the
> billing database to the accounting database. Now the check gets
issued
> from the accounting database after that and the 1099 capital gains
gets
> issued after the check. The time that elapses between the checks and

> 1099's is the problem, because people move, they change their names
etc.
> etc. What I want to do is audit the accounting data against the
current
> billing data. The records have a common account number to join, but
I
> don't know how to form a select (or whatever query it may be) accross

> databases. I've only worked the select from within a single
database.
> I would appreciate some help, I am very new to SQL and my experience
is
> limited to the SELECT statement. However, I am willing and
determined
> to learn new and different things. :)
> Thanks in advance,
> Ben|||Ryan-

Thank you very much! Here's what I wrote:

selectCustMast114.dbo.cap_credit.ccracct_num,
CustMast114.dbo.cap_credit.ccracct_ssein,
CustMast114.dbo.cap_credit.ccracct_name,
CustMast114.dbo.cm_address.add_1,
CustMast114.dbo.cm_address.add_2,
Accounting.dbo.cccheck.ccchk_capcredno,
Accounting.dbo.cccheck.ccchk_ssein,
Accounting.dbo.cccheck.ccchk_name,
Accounting.dbo.cccheck.ccchk_add1,
Accounting.dbo.cccheck.ccchk_add2

fromCustMast114.dbo.cap_credit,
CustMast114.dbo.cm_address,
Accounting.dbo.cccheck

whereCustMast114.dbo.cap_credit.add_uid=CustMast114.dbo .cm_address.add_uid
and
CustMast114.dbo.cap_credit.ccracct_num=Accounting. dbo.cccheck.ccchk_capcredno
andAccounting.dbo.cccheck.ccchk_disbursdt > '2004'
and
(CustMast114.dbo.cap_credit.ccracct_ssein <>
Accounting.dbo.cccheck.ccchk_ssein
orCustMast114.dbo.cm_address.add_1 <> Accounting.dbo.cccheck.ccchk_add1
orCustMast114.dbo.cm_address.add_2 <> Accounting.dbo.cccheck.ccchk_add2
)

order by CustMast114.dbo.cap_credit.ccracct_num

Is there an easy way to tag the entries (rows) individually as to which
of the "or" tests that it failed? Or possibly group them by which of the
"or" tests they failed?

Thanks in advance,

Ben

Ryan wrote:
> A guess at what you may need...
> SELECT
> A.CustomerId,
> A.CustomerName,
> A.CustomerAddress,
> B.CustomerName,
> B.CustomerAddress,
> A.Dividend
> FROM
> MyServer.FirstDatabase.dbo.FirstList A
> LEFT JOIN MyServer.SecondDatabase.dbo.SecondList B
> ON A.CustomerId = B.CustomerId
> WHERE
> A.Dividend <> 0.00 AND
> A.Deceased = 0
> ORDER BY
> A.CustomerName,
> B.CustomerName,
> A.CustomerAddress,
> B.CustomerAddress
> I've deliberately left the fields as something obvious (in case anyone
> asks about naming standards etc) so that you can see what basic work
> you would need to do. Please note, I've used aliases against the table
> names as it's always good to do this for ease of reading. I've assumed
> that you want everything from the first list (A) and only the records
> from the second list (B) - hence the left join.
> I've also added a 'Deceased' clause so you can see how to add
> additional statements in the WHERE part of the statment. Obviously you
> will need to substitute the various fields and databases for your own.
> Hope that helps
> Ryan
>
> Ben Wehrspann wrote:
>>Hello-
>>
>>I am trying to audit values between 2 different databases.
>>
>>ie: We send out dividend checks every year, and it is based on how
> much
>>our customers spend with us. Therefore, once a year we allocate our
>>profits to the customers by dumping customer information from the
>>billing database to the accounting database. Now the check gets
> issued
>>from the accounting database after that and the 1099 capital gains
> gets
>>issued after the check. The time that elapses between the checks and
>
>>1099's is the problem, because people move, they change their names
> etc.
>>etc. What I want to do is audit the accounting data against the
> current
>>billing data. The records have a common account number to join, but
> I
>>don't know how to form a select (or whatever query it may be) accross
>
>>databases. I've only worked the select from within a single
> database.
>>I would appreciate some help, I am very new to SQL and my experience
> is
>>limited to the SELECT statement. However, I am willing and
> determined
>>to learn new and different things. :)
>>
>>Thanks in advance,
>>
>>Ben
>|||Ben Wehrspann (ben@.jtt.net) writes:
> Is there an easy way to tag the entries (rows) individually as to which
> of the "or" tests that it failed? Or possibly group them by which of the
> "or" tests they failed?

You would have to throw in columns like this:

assindiff = CASE WHEN CustMast114.dbo.cap_credit.ccracct_ssein <>
Accounting.dbo.cccheck.ccchk_ssein
THEN 1
ELSE 0
END

Note that once you have your base query, you can manipulated like this:

SELECT a, b, COUNT(*)
FROM (SELECT a = ..., b = ...
FROM tbl
WHERE ...) AS x
GROUP BY a, b

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Thursday, March 8, 2012

Compare data and add to table

Hi all,

Newbie here. I was wondering if any of you gurus could answer a question for me. Here is what I need to do (and I stress need):

I have 2 tables.

Table A has 3 columns, column 1 is unique customer numbers, column 2 is ticket numbers, column 3 is empty records.

Table B has 2 columns, column 1 is unique customer numbers (same numbers, although not the same order as Table A) , column 2 is invoice numbers.

I need to compare Table A where records in column 1 match records in column 1 in Table B. Where the records do match, I need to copy the records from Table B, column 2 to Table A column 3.

Can anyone here help me with this, please? It would really get me out of a jam with this, since it is the last step I have to take to finally get this new app rolled out.

Thanks a lot.

MarkSome app, huh?!

update a set Column3 = b.Column2
from TableA a
inner join TableB b
on a.Column1 = b.Column1|||Thank you, thank you, thank you.

As you can see, I am in not a DB admin, nor do I have the resources on had to find the solution to this problem. (or I would have RTFM) Thanks lots, you have relieved me of quite a bit of stress. Thanks again.

I'd buy you a beer if I could.

Mark|||Heineken, please ;)

compare a table with a file.

Hi everybody (yet another newbie :))

I have a table with 12,000 rows. I also have a file with 15,000 rows.

One of the columns of the table has the field oid and that 7 digit number exists in the file with the 15,000 rows. I need to filter the file (15k rows) to the size of the table. Whenever the oid exists in the table I keep the row or whenever the oid filed does not exist in the table I drop the row off the file. I can extract the oid off the table but then I have to bash it the same way with file with the 15k rows. Is it better to do it in SQL or should I shellscript it between the two files? (in that case I should really post in the shellscript forums)

thanks for helping out.

NickFirst u load the flatfile in to a temporary table and use a delete statement to remove the non matching records from teh temp table

Then again export the data from the temp table to flat file.

If Original table is T1 & tmp table is T2

delete from t2 where oid not in (select oid from t1)|||0002020002.000000008P0000000020031217142337CD N0100000226227884000020560116431834 00010001

0002020002.000000008P0000000020031217142337CD N0100000226227884000020550118641512 00010001

Thank you sir :)
Ok I was thinking about it and this is what I thought as well.

Now here is a copy of the content of the flat file:

0002020002.000000008P0000000020031217142337CD N0100000226227884000020560116431834 00010001

(this is one line it may wrap in the post). I am kind of green on SQL loader and I am niot sure how to apprach this. 560116431834 is the oid filed that I am interested. can you substr the SQL loader on character position like in sql?

thanks a million for your help.

Nick|||you could spool the required feild instead to the file...

with the required set options ...

thanks...

Friday, February 24, 2012

Communication between SQL Server and IIS 6

Hello, I'm a newbie here, so please forgive me if the following seems a
little simplistic. My question concerns communication between SQL server
2005 (or SQL server 2000) and IIS 6, on separate boxes. There seems to be a
fair bit of comment, but little consensus from what I can find, on the best
way to achieve this and set it up. Can anyone help with this?
I am particularly confused, as Microsoft seem to recommend installing SQL
Server and IIS on separate boxes (as I have done), but there seems a great
deal of confusion as to how best get them communicating with one another.
If anyone has a definitive solution, I would be most grateful.
I am running Windows Server 2003 on all machines, and all boxes are on a
Network consisting of separate PCs for Domain Controller, SQL Server 2005,
and IIS 6.
--
Many Thanks,
kascommHello Kascomm,
If you use Windows auanthentication to connect to SQL server from IIS, you
need to enable delegation for IIS server. Please refer to the following
articles for details
810572.KB.EN-US HOW TO: Configure an ASP.NET Application for a Delegation
Scenario
http://support.microsoft.com/defaul...KB;EN-US;810572
817384.KB.EN-US HOWTO: Use Kerberos Authentication for Microsoft SQL Server
2000
http://support.microsoft.com/defaul...KB;EN-US;817384
More information
INF: Authentication Methods for Connections to SQL Server in Active Server
Pages
http://support.microsoft.com/defaul...kb;en-us;247931
PRB: "Client Unable to Establish Connection" Error Message When Connecting
from ASP to SQL Server
http://support.microsoft.com/defaul...kb;en-us;253500
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>Thread-Topic: Communication between SQL Server and IIS 6
>thread-index: AcZcDqchB9YteuLzSI2gwzMRINj/Ew==
>X-WBNR-Posting-Host: 81.5.172.177
>From: examnotes <kascomm@.newsgroups.nospam>
>Subject: Communication between SQL Server and IIS 6
>Date: Sun, 9 Apr 2006 12:49:03 -0700
>Lines: 19
>Message-ID: <9ABAD085-5986-4061-9D63-3828549DA3CD@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
>Newsgroups: microsoft.public.sqlserver.security
>Path: TK2MSFTNGXA01.phx.gbl
>Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.sqlserver.security:26988
>NNTP-Posting-Host: TK2MSFTNGXA01.phx.gbl 10.40.2.250
>X-Tomcat-NG: microsoft.public.sqlserver.security
>Hello, I'm a newbie here, so please forgive me if the following seems a
>little simplistic. My question concerns communication between SQL server
>2005 (or SQL server 2000) and IIS 6, on separate boxes. There seems to be
a
>fair bit of comment, but little consensus from what I can find, on the
best
>way to achieve this and set it up. Can anyone help with this?
>I am particularly confused, as Microsoft seem to recommend installing SQL
>Server and IIS on separate boxes (as I have done), but there seems a great
>deal of confusion as to how best get them communicating with one another.
>If anyone has a definitive solution, I would be most grateful.
>I am running Windows Server 2003 on all machines, and all boxes are on a
>Network consisting of separate PCs for Domain Controller, SQL Server 2005,
>and IIS 6.
>--
>Many Thanks,
>kascomm
>