Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:21:43+00:00 2026-06-17T22:21:43+00:00

My vendor sent over a piece of SQL code that I’m having a hell

  • 0

My vendor sent over a piece of SQL code that I’m having a hell of a time getting to function with my existing query.

I have a webpage that is querying a database table for multiple values here’s the code I have in the ASP page that queries SQL:

SELECT [Account],
[AccountName],
[ComputerName],
[EMail],
[Telephone],
[Status],
cast(cast([StartDate] as float) as datetime) as 'Start-Date',
cast(cast([LastBackupDate] as float) as datetime) as 'LastBackup-Date',
[TotalFileSize],
[TotalFileCount] 
FROM ExpandedView WHERE loginid = @0

This query works great, but the “Account” field specified above apparently returns only part of the actual account number. Apparently my vendor uses a computation to create the final account number and they’ve sent it to me:

use <databasenamehere>
select left(
convert(nvarchar,E.Account)
,5)+'-'+convert(nvarchar,
( 50 +((E.Account)%10)
-((E.Account/10)%10)
+((E.Account/100)%10)
-((E.Account/1000)%10)
+((E.Account/10000)%10)
-((E.Account/100000)%10)
+((E.Account/1000000)%10)
-((E.Account/10000000)%10)
+((E.Account/100000000)%10))
%10 )
+right(convert(nvarchar,E.Account),4) 
as 'Account', AccountName from ExpandView E
Inner Join Customer C
on E.Account=C.Account

Now I realize that that this query is selecting the first 5 numbers of the account number, appending the hyphen and then performing a mathematical procedure to the last 4 numbers, however I cannot figure out how to read this. Could I simply append these two statements together with an “AND” clause?

I really would like to understand what the “E.Account” refers to and why they use a “ExpandView E” and “Customer C” in the query. I’m also kind of lost how those relate to the actual tables.

Any assistance would be appreciated. Or if you prefer, post a link and I’ll read up as best I can.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:21:44+00:00Added an answer on June 17, 2026 at 10:21 pm

    Here’s the query I discovered that seems to work:

    select left
    (convert(nvarchar,E.Account)
    ,5)+'-'+ convert(nvarchar,
    ( 50 +((E.Account)%10)
    -((E.Account/10)%10)
    +((E.Account/100)%10)
    -((E.Account/1000)%10)
    +((E.Account/10000)%10)
    -((E.Account/100000)%10)
    +((E.Account/1000000)%10)
    -((E.Account/10000000)%10)
    +((E.Account/100000000)%10))%10 )
    +right(convert(nvarchar,E.Account),4)
    as 'Account',
     E.AccountName,
     E.ComputerName,
     E.regloginid,
     E.EMail,
     E.Telephone,
     E.Community,
     E.Status,
     CAST(cast(e.startdate as float) as datetime) as 'Start-Date', 
     CAST(cast(e.lastbackupdate as float) as datetime) as 'LastBackup-Date',
     E.TotalFileSize,
     E.TotalFileCount
     from ExpandedCustomerView E Where E.Status = 'A' and E.regloginid = @0 
    

    It seems that the query they are using renames the database table to preface it with E.xxxxx
    I’m not certain how this works. I’m not terribly familiar with MSSQL to understand why they are calling a rename of the parameters in the select. However this query works without issue and provides the data I need.

    Perhaps if someone can answer why they would use a parmeter around the “FROM EXPANDEDVIEW E” portion? That seems to be the point at which the renaming of the columns occurs.

    Anyways, I’d be interested to know, but this definitely works for me, so I’m going to close this out. Thank you everyone for your answers/comments and help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A vendor has a data database (read only) that gets sent to us via
Having an assembly which I cannot modify (vendor-supplied) which have a method returning an
I'm creating a sub dialog another vendor is calling. I'm having trouble reading the
I am getting an EOFError (End Of File Error) on this code in my
We have a vendor that sends CSV files as email attachments. These CSV files
We have a vendor portal that is public and a Moodle site that is
I've used sqlite before. My friend sent me a skeleton rails app that I
We have a vendor-provided Jar that contains a class we wish to extends and/or
A vendor is supplying a 1MB XML file that updates every minute. I need
We work with a vendor that sends us various different XML messages that we

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.