How to Create a new Table with another Table data (replicate)

I search for a table and open it, and now I must implement an option to Replicate the table with another name(month/year) and the same Data.

Looking in the web I just found about script´s but I don´t understand about data bases scripts.

 

Plz sugestions, ideas, codes =]

thx

(using visual studio 2005, SQL Server)

 

0
vmDillenburg
9/10/2008 2:09:32 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

2 Replies
876 Views

Similar Articles

[PageSpeed] 9
Get it on Google Play
Get it on Apple App Store

You can use SELECT INTO to copy data to another table:

SELECT * INTO newTableName FROM oldTable

If you want to do this on the fly, you can use a stored procedure like a sample below:

CREATE PROCEDURE usp_myNewTable

AS

BEGIN

declare @tName nvarchar(50)

declare @sql nvarchar(200)

SET @tName='my'+CAST(Month(getdate()) as nvarchar(2))+CAST(Year(getdate()) as nvarchar(4))

SET @sql='SELECT * INTO '+ @tName + ' FROM oldTable'

execute sp_executesql @sql

END

GO


Limno

0
limno
9/10/2008 2:47:36 PM

 GREAT REPLY...

THANKS!

ANSWER

 


0
vmDillenburg
9/11/2008 11:38:00 AM
Reply:

Similar Artilces:

is there an sql statement to insert data to one table and getting the data from another table
Ok I have a table that have general categories with just name and CatNo. Now what I want to know is when I create a client to move all the data in general categories to another table called categories that have the clientid to associate it with the client. I would appreciate for any help what is your question here??Shravan Addaypally MCP...

how to create a new sql table from xml table through coding
I have a xml tableProgramatically I have to convert the data to sql table and show the data in the grid view from the sql tableall I have to do by coding onlycan it be possible  Hi, As far as I know Torque can generate SQL source from an XML schema describing a database structure: http://db.apache.org/torque/releases/torque-3.1.1/generator/ However you need to do that throught coding which is not as simple as it sounds. You may have to transform xml schema to sql schema manually or use xslt. Or you can load xml schema into dataset and create database schema from dataset. Hop...

how to create a new table based on the data from a old table
if I am doing normalization, I want to delete some rows from an existing table then create a new table base on these data. For exaple I have a talbe like this 'Bill',2 'Bill',2 'mary',9 my statement is select name,id from tp group by name, id; then the output is bill 2 mary 9 this is the contents of my new table I want. How can I create this new table with a new name? Try SELECT Distinct Jim <gretp> wrote in message news:AB9E253F765BD220002B503F852569F1.002B5059852569F1@webforums... > if I am doing normalization, I want to delete some rows...

creating a table column that only takes data from another table.
I am trying to create a table that holds info about a user; with the usual columns for firstName, lastName, etc....  no problem creating the table or it's columns, but how can I "restrict" the values of my State column in the 'users' table so that it only accepts values from the 'states' table?ScottSEADont forget to click "Mark as Answer" on the post that helped you!This credits that member, earns you a point and mark your thread as Resolved for the sake of Future Readers. You could create a trigger on the table or a rule?***********************Dinakar NethiLife is short. En...

Updating a Table data from Another table using Sql Server 2000
Hi All, I have a Problem while updating one table data from another table's data using sql server 2000. I have 2 tables named TableA(PID,SID,MinForms) , TableB(PID,SID,MinForms) I need to update TableA with TableB's data using a single query that i have including in a stored procedure. use this type of query  update myTable2 set SID= (select top 1 SID from myTable1)Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever. u can use SELECT column_name(s) INTO newtable [IN externaldatabase] FROM sourcee.g.SELECT * INTO Persons_backup...

Creating a Table from another Table.
I need to be able to create a temporary table that is exactly like an existing table. In Oracle, the syntax to do this was as follows: CREATE TABLE NEWTABLE AS (SELECT FROM EXISTINGTABLE); This effectively copies the table structure and creates a table called newtable that is a "clone" of the existing table. How can this be accomplished in SQLA, short of writing a stored procedure or a function? Thanks for your response. Owen Hebert Consolidated Services Corp SELECT * INTO NewTable FROM OldTable Dave Wolf Jaguar Product Team Owen Hebert wrote: > I...

How to create SQL Tables from Random XML files and Upload its data to those tables
Hi,I was wondring if there is a way to automatically create SQL Tables when an XML file is uploaded and load its data to that SQL table? So here is what I was thinking:1- Create a xsd file from that XML2- Create the SQL Table from that xsd3- Upload the data to that table. Is this possible? I have done something like this before, but the colum data type is Variant which I don't want.             using Microsoft.SqlServer.Management.Common;            using M...

Create new table
Hi,I am creating a new table called 'tableA'TableA has 2 columns - columna and columnb..I would like the values of tableA's columna to be the same as tableBs' (a current table) columna...Does that make sense?Can I use a computed column? Will it still work if table b's columna has new data added all the time (will tablea keep up to date?) Thanks,Jon  In the sense you want to and fro values to be same from both the tables.I think its a one way possibility but not the two way here is the query take the wizard and follow the steps in the sense 1)in ur BLL def...

How to move data from one table to another table w/o affecting the table definition?
Hello All! I have a production server and a development server. On the production server, I have a table (thin a database) that already contains data. On the development server, I created a table (still within another database) and I want that table of the development server to contain the data from the table of the production server. But, both tables don't have the same table definition, meaning in the table of the development server, I have added a new column named ID that I want to use as a primary key column, but I don't have tha...

How to select data from a table and insert the selected data in the same table as new row
Hi    I have a table called Version and its attributes are Version_ID, Project_ID , Hospital_ ID , Date_Created and comments. I want to select the data by Version_ID,Project_ID and  Hospital_ID and the selected data is inserted in the same table(Version) as new row . Table: Version (Version_ID(Primary_key), Project_ID(Foreign_Key),Hospital_ID(Foreign_Key),Date_Created,Comments).  Iam using Visual Web Developer Express 2005 and SQL Server 2005. Iam doing on asp.net 2.0. Could anyone please send me the code in asp.net 2.0 for the above problem. ...

How do you copy table data to another table?
I need to copy existing row data from one table into a new row in a different table, both in the same database.  Can this be done in a stored procedure where the selected row is passed in as parameter value? Thank you, There's plenty of ways you can do this.Try INSERT INTO YourTable (.column list) SELECT (columnlist) FROM YourTable WHERE <Condition>  ***********************Dinakar NethiLife is short. Enjoy it.*********************** that easy? thank you.  I am getting that 'can't see the forest for the trees' feeling....

How to create a table with datarow from another table?
 Hi, I am trying to display a table with values obtained from a datarow of another table. The purpose of this is because I want to create a table showing a list of records that were updated. (meaning records not updated would not show in table)Usually, I would fill a dataset and just add a new row. However, there is no dataset I would like to fill. I want a blank dataset/ datagrid, and just add rows with fields in it. I figure either:1) fill a blank dataset and add rows into it, or2)create a table and add rows into it. I am not sure 1 can be done, so.....I am guess 2 is more likely. Can...

How to create a temporary table from another table
HI! Please tell me how to create a temporary table from another table ? give me a example,any advise is appreciate! Please post this question in the ASE.General newsgroup. This group is for EAServer issues. Regards, Dave Fish [TeamSybase] On Sat, 2 Mar 2002 23:12:16 -0500, yfz wrote: >HI! > Please tell me how to create a temporary table from another table ? >give me a example,any advise is appreciate! ...

Create new Table from existing table
Hi I'm trying to Create a new Table from existing table in Q/Analyzer. I figured it would be something like this: CREATE TABLE newTable AS(SELECT * FROM OldTable); but i keep getting Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'AS'. also.. is there another method of doing this, something like INSERT INTO newTable(SELECT * FROM OldTable); and it creates the table ( newTable ) for u if it doenst already exist?? Cheers!!! im using sql2000 You can try this one: SELECT * INTO newTable FROM OldTableLimno The easiest method to copy ...

Web resources about - How to Create a new Table with another Table data (replicate) - asp.net.sql-datasource

AppData: JibJab Replicates ElfYourself Success on Facebook
Jibjab’s ever popular creation, ElfYourself, is a major digital marketing success story. Building on the campaign’s success last year, this holiday ...

A year later, Warner hopes to replicate masterclass
IT'S almost a year to the day since David Warner played the most character-revealing and necessary innings of his young career. Not the awe-inspiring ...

Lego exhibition replicates global landmarks (01:40)
RAW VIDEO: an exhibition in Poland recreates some of the world's most iconic landmarks including Paris' Eiffel Tower, London's Tower Bridge, ...


Anti-Islam campaigner Geert Wilders video replicates controversial 'No Way' campaign
Standing in front of a backdrop showing a tiny boat being tossed in treacherous waves, and emblazoned with an&nbsp;emphatic slogan telling refugees ...

Lego exhibition replicates global landmarks (01:40)
RAW VIDEO: an exhibition in Poland recreates some of the world's most iconic landmarks including Paris' Eiffel Tower, London's Tower Bridge, ...

Tedesco told to replicate Dugan
James Tedesco doesn't think he will play State of Origin this year but a little bit of versatility might just go a long way.

Lost skills revived to replicate a medieval minbar
THE fire spread quickly. It was the morning of August 21, 1969, and a young Australian sheep shearer, Dennis Michael Rohan, left the al-Aqsa ...

State of Origin: Morris boys split as Blues hope to replicate Greg Inglis' quiet opening game
The Blues will resist the temptation of pairing the Morris brothers on the same side of the field as they brace for a firing Greg Inglis in game ...

Lego exhibition replicates global landmarks (01:40)
RAW VIDEO: an exhibition in Poland recreates some of the world's most iconic landmarks including Paris' Eiffel Tower, London's Tower Bridge, ...

Resources last updated: 1/22/2016 2:16:25 AM