Thursday, March 8, 2012
copying data from a foreign database to Sql Server 2000
data from a foreign database that will have an ODBC connection.
This task will need to be executed at night or from a .NET web page and
I was wondering what would the best way to copy the data from this
procedure.
It won't be necessarily be copying all the data from the database, but
could copy selected tables at different times.
Is this easily done from a Stored Procedure?
Thanks,
Tom.I would play with DTS if I were you. Seems a better candidate than a sproc
without using Linked Servers and such...
Greg Jackson
PDX, Oregon|||Jaxon wrote:
> I would play with DTS if I were you. Seems a better candidate than a sproc
> without using Linked Servers and such...
>
The question is, can it be run from ASP.NET? They want to run this
during the day when necessary, not just at a particular time of day and
don't want to run it from EM.
Tom.
> Greg Jackson
> PDX, Oregon
>
>
Sunday, February 19, 2012
Copy table Structure including primary keys, index etc.
Hi all,
I was wondering if there is a SQL command to copy the table structure of a table that includes primary keys, foreign keys, indexes, etc.
Thanks and have a nice day to all
Not a SQL command, but you can script this stuff out using the tools by right clicking the table, or programatically using SMO.
|||can you post a sample script or SMO please or send me a link discuss this matter thanks|||
Hi,
The easiest way to create the script is to right click the original table within SQL Server Management Studio and select "Script Table As ...\ Create To\ ..." . This will create a script for the table and its indexes.
Then you need to run the script but with the new tablename. After that, you need to copy the records using a insert/select command. (it is best to set the constraints/indexes afterwards).
Greetz,
Geert
Geert Verhoeven
Consultant @. Ausy Belgium
My Personal Blog
|||I was thinking to use that script in my SP, On my SP I add a linked server then i want to copy all the tables exactly the same
and on the linked server the table names and table count change everyday, but i dont have any problem with that.
I was thinking if there is a way to copy exactly the same table inside an SP in that case.
Thanks
|||You can use sys tables/views inside your SP|||can you post your samples script please.
thanks
|||
SELECT * INTO NewEmployee FROM Employee WHERE 1 = 0
above query will create same structure table called NewEmployee with structure of Employee. But will not have triggers and primary keys etc. you can create them by using follwing scripts
SELECT *
FROM sysobjects
WHERE parent_obj = OBJECT_ID('Employee')
SELECT *
FROM syscomments
WHERE id IN ( SELECT id
FROM sysobjects
WHERE parent_obj = OBJECT_ID('Employee') )
|||thanks for the reply Dinesh. Nice sql Stmt, does this work when you have a MS Access linked Server, is there a sysobjects table on the linked server?