Okay, this is probably a simple one for someone other than me. :) So I built this elaborate query in SSMS to construct a restore command. It works very nicely in SSMS. However, when I put it into an execute SQL task in SSIS, it errors with:
insert error: Column name or number of supplied values does not match table definition
I've stripped the query down as much as I can, to eliminate any other confusion here. Here's the stripped down version, that if you copy/paste into SSMS, and edit for one of your .bak files (name and location) you will see works nicely. However, it does not work in execute SQL query task. Again, this query serves no useful purpose as it is. I have it doing much more, to output the entire restore command, complete with file extensions, etc. that I then want to output to a variable to then later execute. (backing up on one server, restoring on another). I'm guessing that rather than doing the exec and getting the results to insert, it is attempting to insert the "exec(...) into the table, but not sure how to fix that either. I only use the below, to understand why this portion (straightforward) does not work in the SQL task.
Please help. :(
DECLARE @RestoreCommandTable table
(
LogicalName nvarchar(128),
PhysicalName nvarchar(260),
Type char(1),
FileGroupName nvarchar(128),
Size numeric(20,0),
MaxSize numeric(20,0),
FileID bigint,
CreateLSN numeric(25,0),
DropLSN numeric(25,0),
UniqueID uniqueidentifier,
ReadOnlyLSN numeric(25,0),
ReadWriteLSN numeric(25,0),
BackupSizeInBytes bigint,
SourceBlockSize int,
FileGroupID int,
LogGroupGUID uniqueidentifier,
DifferentialBaseLSN numeric(25,0),
DifferentialBaseGUID uniqueidentifier,
IsReadOnl bit,
IsPresent bit,
TDEThumbprint varbinary(32)
)
INSERT INTO @RestoreCommandTable exec(N'RESTORE filelistonly FROM DISK = N''\\myserver\SQL2005\MSSQL.4\MSSQL\backup\mydatabase.bak''')
Thanks in advance!
mpleaf