Results 1 to 3 of 3

Thread: scripts to create table

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    scripts to create table

    I have my table 'Category' which have 30 rows.
    just asking on how can I create script to create new table 'Category' and it will include the 30 rows of it?


    thanks in advance

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: scripts to create table

    You didn't mention what database you are using. For SQL 2005 you can:

    Select * into NewCategory from Category.

    If you don't want to rename it you'll need to do something like:

    Select * into #TempCategory
    Drop table category
    select * into Category from ##TempCategory

    It would help to know what you are trying to achieve.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: scripts to create table

    I think the OP is asking how to create a script that when run, will create the table and insert the values into it ... creating the table is easy... from SSMS, you can right-click the table, select Script As -> Create -> New Window... and that will generate the script to create the table. The insert data... that's going to take a little more effort as there isn't an automatic way to do that... but unless it's uber complicated, it's probably just as easy to write it by hand...

    update - as I was writing that up, it occurred to me that I might have something in my bag o' tricks... sure enough... I have a script that will script the data of a table into insert statements... all you have to do it open it in SSMS, using the right database, point it at the table, set a couple of option and run it... documentation is in the script. I PROVIDE IT WITH NO SUPPORT OR WARRANTY, USE AT YOUR OWN RISK.

    -tg
    Attached Files Attached Files
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width