March 4, 2008 at 12:19 pm
i have a file c:\\abc.txt
in which i have some data so i jus need to import data from that file to db so i jus used import export wizard but here the problem is that i need to get a new column naming "source file" with the c:\\abc.txt as data in that column for the whole data ....i have some other files c:\\abc1.txt which i should import to the same table now i should get c:\\abc1.txt for the data in the column 'source file" for eg
name id sourcefile
abc 1 abc.txt
abcs 2 abc.txt
agh 3 abc.txt---imported from file abc.txt
hdsj 4 abc.txt
ancb 5 abc1.txt
ahdhd 6 abc1.txt--imported from fil abc1.txt
adshd 7 abc1.txt
deg 8 abc2.txt--imported from fil abc2.txt
sah 9 abc2.txt
asaj 10 abc2.txt
so i shouls have all this data in a single table but i need to add a new column with the column data to be changed according from which file it has come from ...other than ssis how can i do that in ssms..
can i manually type the sourcefile name in the import at first..if so how can i do that please let me know its urgent thkz in adavance.....
Thanks,
Chinna
Its the Journey which gives you Happiness not the Destination-- Dan Millman
March 4, 2008 at 3:02 pm
So you only need to do this once, or you need to automate it?
If you just need to do it once, how many files are there? Why not just do it manually and go update the columns that are NULL with the name of the file you just imported, in the database?
If you want to automate it, I'd say use the For Each loop to loop through the files. Then set the file name to a variable, which I believe it actually does for you (User:FileName) then pass the variable to a parameter in a SQL Task, and update the null rows to the variable value you passed in.
Hope that helps,
Rick Todd
March 4, 2008 at 3:09 pm
This is a double-post. There's another copy of the exact same question in the T-SQL 2k5 forum. More replies there.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply