?
Solved

User-Defined Tables

Posted on 2012-08-15
3
Medium Priority
?
357 Views
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));
0
Comment
Question by:jphilli
3 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 38297914
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
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38297922
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
GO

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.
0
 

Author Closing Comment

by:jphilli
ID: 38297960
Thank you very much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

840 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