Thread: Query help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2006
    Posts
    7
    Rep Power
    0

    Query help (Resolved)


    I have a table that has about 70,000 records that i need to create smaller tables from. The table names need to be the distinct value one of the columns.

    So column ID has about 50 different distinct values and I need those distinct values to be the name of each of the 50 new tables that contain all the information associated with that ID....first name, last name, street, etc.

    Does anyone know of a simple way to create all 50 tables with the ID names and all the information associated with the ID rather than creating and running 50 different queries like this

    CREATE TABLE #temp
    (
    ......
    )

    INSERT #temp
    .....
    FROM SourceTable
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Posts
    608
    Rep Power
    16
    use a normal programming language to do the dynamic scripting, or use exec w/ a variable, in a loop.

    exec(@YourQueryThatYouDynamicallyMade)

IMN logo majestic logo threadwatch logo seochat tools logo