Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Creating SQL table with existing data
Last Post 01-18-2011 01:34 PM by Ryan Bakerink. 4 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
jtigerUser is Offline
skipping stones
skipping stones
Posts:11
Avatar

--
01-05-2011 05:37 PM
    Hi there,

    I'm pretty new at all this and I've been looking at the manuals and tutorials, and I've found tutorials on how to create a new SQL table, but I have not seen anything where I can import existing data (i.e. an excel file) to make an SQL table that I will use for validation.

    I have over 5000 records in this table, so I'd rather not have to enter one by one. :-)  Any assistance in pointing me towards a tutorial for this or simply showing me the steps on how to do this is greatly appreciated.

    Thanks,

    -Jahn
    P.S. I'll probably be asking more questions once I try to set up all the validation, etc.
    jtigerUser is Offline
    skipping stones
    skipping stones
    Posts:11
    Avatar

    --
    01-07-2011 02:28 PM
    I found a way to do this and it worked pretty well. Later I saw some information that you might be able to import an excel or csv file directly, but what I did worked. If anyone's interested, let me know.

    -Jahn
    CandaceUser is Offline
    river guide
    river guide
    Posts:2431
    Avatar

    --
    01-14-2011 11:07 AM
    Hi Jahn,

    Yes, if you can share what you found, that might help someone else.  Thanks!

    Candace
    jtigerUser is Offline
    skipping stones
    skipping stones
    Posts:11
    Avatar

    --
    01-14-2011 11:48 AM
    Glad to help. This might seem somewhat convoluted, but if you follow the steps one at a time it really won't take all that long. I had to do this for a few thousand zip codes, so that is what my example is going to be. Adjust to what you need accordingly.

    So, first you create your table:

    CREATE TABLE thezips
    (id INT IDENTITY (1,1) PRIMARY KEY, <-- this will increment each record you insert by 1
    state VARCHAR (20),
    zip VARCHAR(10),
    city VARCHAR(150),
    county VARCHAR (20)
    );

    the reason the zip column is VARCHAR is because there might be the extended zip (i.e. 12345-1234).

    Now to add all your data:
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07001','Avenel','Middlesex');
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07002','Bayonne','Hudson');
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07003','Bloomfield','Essex');
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07004','Fairfield','Essex');

    ...and so on...

    Instead of writing the INSERT statement over and over, go to MS Excel and make sure your data is in it (i.e. NJ, 07004, Fairfield, Essex), then insert a new column in between each column containing data. Then, starting from the far left column you'll enter the characters and it'll look something like this:
    (' NJ ',' 07004 ',' Fairfield ',' Essex ');

    IMPORTANT: In Excel if you start your entry with an apostrophe ( ' ), then Excel thinks you're forcing the cell to recognize text instead of numeric and the ' will disappear. So, you need to enter a leading ' for those cells that contain ',' so it'll look like this when you enter '','. The first ' will disappear and it will not carry over when you copy and paste later.

    Once you have one row complete, simply copy and paste all the character columns down to match the amount of data you have.

    Then copy and paste your data into a text editor (i.e. Notepad), then copy and paste all the data from your text editor into MS Word. If you omit the text editor, Word will think what you're copying is Excel info and that's not what you want.

    In Word do a Find/Replace (CTRL + F, then click on the Replace tab). In the "Find what:" field type ^t and leave the "Replace with:" field blank. Click "Replace All". Word will tell you how many records it replaced - click "OK". You should now have data that looks like this:
    ('NJ','07004','Fairfield','Essex');

    Now, in the Find/Replace box, in the "Find what:" field type ^p(' and in the "Replace with:" field type ^p('INSERT INTO zipcodes (state,zip,city,county)^pVALUES^p and click "Replace All". The INSERT statement should correspond to whatever your data is. Click "OK".

    Finally, go to the top of the Word doc and make sure that your first statement is correct, then go to the bottom of the Word doc and delete any extraneous code that was inserted due to extra returns. When you're done you will end up with code that looks something like this:
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07001','Avenel','Middlesex');
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07002','Bayonne','Hudson');
    INSERT INTO zipcodes (state,zip,city,county)
    VALUES
    ('NJ','07003','Bloomfield','Essex');

    Now copy and paste this back into a text editor (Notepad) in order to get rid of any weird, hidden Word characters, then copy and paste the data from the text editor to your SQL editor to execute the code.

    Like I said, several steps, but just follow one by one and it'll work out.

    Let me know if you have any questions. Good luck.

    -Jahn
    Ryan BakerinkUser is Offline
    river guide
    river guide
    Posts:1900
    Avatar

    --
    01-18-2011 01:34 PM
    Hello Jahn,

    Thank you for your contributed time and knowledge embedded into your forum post.

    If you ever have any questions please let us know.

    Thanks,

    Ryan
    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way
    Subscribe Me

    Recent Blogs...

     
    Copyright 2005 - 2011 by Data Springs, Inc.
     
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi