![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi there, I am using DTS script for the conversion. I would like to get a database name as a parameter from the user (through a command line), assign it to the package global variable, and then use Execute SQL task to drop and recreate a database with such name. However, I have troubles passing a parameter to Execute SQL task. The following syntax works: DECLARE @ArchiveName VARCHAR SET @ArchiveName = 'Conversion' IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = @ArchiveName) BEGIN EXEC ('DROP DATABASE' + @ArchiveName) END However, I need @ArchiveName to be a parameter set by user. Any attemts to use parameters in Execute SQl task throw error: DECLARE @ArchiveName VARCHAR SET @ArchiveName = ? IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = @ArchiveName) BEGIN EXEC ('DROP DATABASE' + @ArchiveName) END And this: IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = ?) BEGIN EXEC ('DROP DATABASE' + ?) END Please let me know if you know how to make it work Thanks a lot Irene |
#3
| |||
| |||
|
|
Hello Irene, Have a look at this article to see how to accomplish this http://www.sqldts.com/default.aspx?205 Regards Allan Mitchell Konesans Ltd T +44 7966 476 572 F +44 2071 008 479 http://www.konesans.com Hi there, I am using DTS script for the conversion. I would like to get a database name as a parameter from the user (through a command line), assign it to the package global variable, and then use Execute SQL task to drop and recreate a database with such name. However, I have troubles passing a parameter to Execute SQL task. The following syntax works: DECLARE @ArchiveName VARCHAR SET @ArchiveName = 'Conversion' IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = @ArchiveName) BEGIN EXEC ('DROP DATABASE' + @ArchiveName) END However, I need @ArchiveName to be a parameter set by user. Any attemts to use parameters in Execute SQl task throw error: DECLARE @ArchiveName VARCHAR SET @ArchiveName = ? IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = @ArchiveName) BEGIN EXEC ('DROP DATABASE' + @ArchiveName) END And this: IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = ?) BEGIN EXEC ('DROP DATABASE' + ?) END Please let me know if you know how to make it work Thanks a lot Irene |
![]() |
| Thread Tools | |
| Display Modes | |
| |