Reply to giving a proc database and table names as parameters

Your name:

Reply:


Posted by Muhammed Al-Khoutani on 01/10/07 12:22

Hello!

Is it possible to pass a stored procedure a parameter, say @table and
use it as a table in the sql command?
Finally i want a proc to copy tables from a database to another database.

THERE IS MY CODE:

CREATE PROCEDURE [user].[copytable]
@dbSRC varchar(100),
@dbTRGT varchar(100),
@table varchar(100)
AS

BEGIN TRANSACTION FreeAndCopyTable
TRUNCATE TABLE [@dbTRGT].admin.[@table]
INSERT INTO [@dbTRGT].admin.[@table]
SELECT *
FROM [@dbSRC].admin.[@table]

COMMIT TRANSACTION FreeAndCopyTable
IF @@error <> 0 GOTO E_Copy_Fail

E_Copy_Fail:
ROLLBACK TRANSACTION FreeAndCopyTable

GO

thanks in advance,
muh

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация