home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
moodle.waes.ac.uk
/
moodle.waes.ac.uk.zip
/
moodle.waes.ac.uk
/
TMG
/
SP1-TMG-KB981324-AMD64-ENU.msp
/
PCW_CAB_SHFx2
/
F2143_msfpcui.dll
/
BINARY
/
25522
< prev
next >
Wrap
Text File
|
2010-06-15
|
1KB
|
34 lines
CREATE PROCEDURE [dbo].[ISA_spDuplicateEmptyTable]
@SourcetblName varchar(100),
@TargetTblName varchar(100),
@DeleteExisting Int
AS
BEGIN
SET NOCOUNT ON;
DECLARE @strSQL varchar(500)
PRINT 'Source Table ' + @SourcetblName
PRINT 'Target Table ' + @TargetTblName
IF OBJECT_ID (@TargetTblName, 'u') IS NULL
BEGIN
PRINT 'Table ' + @TargetTblName + ' no found. going to duplicate'
SET @strSQL = 'SELECT * INTO [dbo].' + @TargetTblName +
' FROM ' + @SourcetblName +
' WHERE 0 = 1'
PRINT 'Executing: ' + @strSQL
EXECUTE (@strSQL)
PRINT 'Table ' + @TargetTblName + ' created'
END
ELSE
BEGIN
PRINT 'Table ' + @TargetTblName + ' already exists. no need to duplicate'
IF (@DeleteExisting = 1)
BEGIN
PRINT 'Table ' + @TargetTblName + ' should be truncated first. truncating'
SET @strSQL = 'TRUNCATE TABLE ' + @TargetTblName
PRINT 'Executing: ' + @strSQL
EXECUTE (@strSQL)
PRINT 'Table ' + @TargetTblName + ' created'
END
END
END