This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Thursday, April 12, 2012
Excel to SQL-Server Insert in vba apostrophe in sql
Tuesday, April 10, 2012
Execute SSIS package -dtexec
EXEC xp_cmdshell 'dtexec /FILE "C:\\Package.dtsx" /SET \Package.Variables[User::FileName].Properties[Value];"C:\\linkservertest.xlsx"'
in batch command
dtexec /FILE "C:\\Package.dtsx" /SET \Package.Variables[User::FileName].Properties[Value];"C:\\linkservertest.xlsx"
Monday, April 9, 2012
Excel sql SSIS with variable file name
-- exec dbo.import_data 'C:\Documents and Settings\varunj\My Documents'
ALTER procedure dbo.import_data
@FilePath varchar(2000)
--@filename varchar(2000)
as
declare
@sql nvarchar(50),
@Bank_code numeric(35),
@Bank_transaction numeric(35),
@Money_trn numeric(35),
@Check_num varchar(25),
@FilePath varchar(2000),
@dtsname varchar(1000),
@cmd varchar(2000)
set @dtsname = 'Package.dtsx'
select @cmd = 'DTExec /F "' + @FilePath + @dtsname + '"'
print @cmd
set @sql = ''
--insert new records
insert into dbo.import_data2 (Bank_code,Bank_transaction, Money_trn, Check_num )
select a.Bank_code,a.Bank_transaction, a.Money_trn, a.Check_num
from dbo.import_data1 a left join
dbo.import_data2 b
on a.bank_code=b.bank_code
where b.bank_code is null
-- update existing records
update dbo.import_data2
set money_trn = x.Money_trn, Bank_code = x.Bank_code, Bank_transaction = x.Bank_transaction, Check_num = x.Check_num
from
(select a.Bank_code,a.Bank_transaction, a.Money_trn, a.Check_num
from dbo.import_data1 a join
dbo.import_data2 b
on a.bank_code=b.bank_code) x
where import_data2.bank_code = x.bank_code
--clean up import_data1 (temp table)
truncate table dbo.import_data1
exec master..xp_cmdshell @cmd
GO
Excel SpreadSheet variable Filename to SSIS
I created a simple package (using BIDs on a 32-bit machine) that contains an Excel Source & OLE DB Destination, Excel Connection Manager, and an SSIS variable that stores the full path to the Excel file. The package runs successfully. Here are the steps I followed. I hope this is helpful in resolving the error you're getting:
1. Added Excel Source.
2. Added Excel Connection Manager, clicked Edit, and entered the full file path in the Excel file path box (C:\Work\Excel Folder\TestBook97.xls). Saved changes.
3. Configured the Excel Source to point to the connection manager.
4. Added a string variable to the package, confirmed that the variable scope was Package, and filled in the variable value (C:\Work\Excel Folder\TestBook97.xls).
5. Added an expression to the Excel Connection Manager, to set value of the ExcelFilePath property using the string variable.
6. Connected the Source to the Destination.