1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Extract SQL data to specific columns

Discussion in 'Business Applications' started by Tony414, Apr 23, 2013.

Thread Status:
Not open for further replies.
Advertisement
  1. Tony414

    Tony414 Thread Starter

    Joined:
    Nov 21, 2006
    Messages:
    163
    Hello,
    I'm hoping someone can lead me in the right direction here. I have a sql query that was written for me some time ago. I need to have the data placed in specific columns and rows within the csv file. Is it possible for me to do this? Here is what I have below... Lets say I need to place "ASSRREAL.Street" in column D row 3 of the csv file. Any help or ideas would be great. Thanks

    SET NOCOUNT ON;
    SELECT '"' + RTRIM(ASSRREAL.Unique_id) + '"' AS Uniqueid,
    '"' + RTRIM(ASSRREAL.Taxpayer) + '"' AS Name,
    '"' + '"' As Name2,
    '"' + RTRIM(ASSRREAL.In_Care_Of) + '"' AS Careof,
    '"' + RTRIM(ASSRREAL.Street) + '"' AS Address1,
    '"' + RTRIM(ASSRREAL.Street_Mailing_Addr2) + '"' AS Address2,
    '"' + RTRIM(ASSRREAL.City) + '"' AS City,
    '"' + RTRIM(ASSRREAL.State) + '"' AS State,
    '"' + RTRIM(ASSRREAL.Zip1 + ASSRREAL.Zip2) + '"' AS Zipcode,
    ASSRREAL.Acreage AS Acres,
    '"' + RTRIM(ASSRREAL.Map_Block_Lot + Xtr_Mbl) + '"' AS MBL,
    '"' + CONVERT(varchar(5), ASSRREAL.Volume) + '"' AS Volume,
    '"' + CONVERT(varchar(5), ASSRREAL.Page) + '"' AS Page,
    '"' + RTRIM(LTRIM(ASSRREAL.Prop_Loc_St_No)) + '"' AS Street_Number,
    '"' + RTRIM(ASSRREAL.Prop_Loc_St_Name) + '"' AS Street_Name,
    '"' + RTRIM(ASSRREAL.Prop_Loc_Unit) + '"' AS Street_Unit
    FROM ASSRREAL
    WHERE ASSRREAL.Delete_Flag = 'N' AND
    ASSRREAL.GSequence = 0 AND
    ASSRREAL.Record_Year = 2013
    ORDER BY ASSRREAL.Prop_Loc_St_Name, ASSRREAL.Prop_Loc_St_No, ASSRREAL.Prop_Loc_Unit
     
  2. Tony414

    Tony414 Thread Starter

    Joined:
    Nov 21, 2006
    Messages:
    163
    Hi again!

    I'm still trying to figure out the best possible way to do this? I am not a programmer but I'm thinking this could be done in Excel with some sort of VB script. Here is some technical info on this.
    Server name is TA-SERVER
    Database name is QDS with sa and blank password
    Table name is ASSRREAL
    Here are a few field names UNIQUE_ID,TAXPAYER, STREET

    I would need to place
    UNIQUE_ID in column A
    TAXPAYER in column D
    STREET in column H

    If anyone can get me started that would be great :) Thank you
     
  3. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    Are we to assume you are using MS Access? If so you need to use VBA to create a recordset from your SQL statement. Once you get this part working we can help with the rest of the code to move the recordset data to Excel. Check out the link I provided below.

    http://www.utteraccess.com/wiki/index.php/Recordsets_for_Beginners

    Rollin
     
  4. Tony414

    Tony414 Thread Starter

    Joined:
    Nov 21, 2006
    Messages:
    163
    I'm actually not using anything yet. Just trying to figure this all out. The SQL code that I posted was from my vendor which doesn't want to help out anymore. They want to charge a very large amount to do it. So I posted pretty much what I need done. One thing I left out is I would also need it scheduled to run every night if possible. If not maybe a macro in Excel might do the job? I know very little about this. Just some basic stuff...
     
  5. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    We need to know what type of database before we can offer any suggestions or help.


    Rollin
     
  6. Tony414

    Tony414 Thread Starter

    Joined:
    Nov 21, 2006
    Messages:
    163
    The database is MS SQL Server 2000
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1096904

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice