User-Defined Tables

Posted on 2012-08-15
Last Modified: 2012-08-15
I need to create a user defined table to insert data for two additional faculty members into my adjuncts table.
My table is set up like this:

(Faculty_ID Char(1),
LastName VARCHAR(20),
FirstName VARCHAR(20),
Department VARCHAR(10),
Campus VARCHAR(10),
Term CHAR(1));
Question by:jphilli
    LVL 39

    Accepted Solution

    select top 1 * itno #tmp from <table>

    delete from #tmp

    #tmp is now an exact copy of your table.

    insert into #tmp (Faculty_ID, LastName, FirstName . . .)
    values ('A', 'AB', 'ABC'. . . )

    insert into <table> select * from #tmp
    LVL 65

    Expert Comment

    by:Jim Horn
    Okay.  The below T-SQL creates the table.   Replace YourTableName with whatever you want to name it.

    IF OBJECT_ID('YourTableName') IS NOT NULL
          DROP TABLE YourTableName

    CREATE TABLE YourTableName
          (Faculty_ID Char(1),
          LastName VARCHAR(20),
          FirstName VARCHAR(20),
          Department VARCHAR(10),
          Campus VARCHAR(10),
          Term CHAR(1))

    >to insert data for two additional faculty members into my adjuncts table.
    So .. you have faculty and adjuncts tables?  More details please.

    Author Closing Comment

    Thank you very much!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now