Author |
Topic |
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 13:28:10
|
Is there a function like Now() or a routine that will allow me to capture the name of the file and dynamically populate a column called 'Filename' within that same file?Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-04 : 13:37:53
|
What file are you referring to?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 13:47:49
|
Hi Tara! It's been awhile since I posted last.....anyway, the question is for any given file, I want to stick the name of the file in a column within itself before I append it to a larger file. The purpose is to identify what file the record belonged to if it should pop up as an error. For example: File name is "Q2_2008_Pi_Orionis". I'm appending to "QA_2008_Stellar_Cumulative". The mega file has already been appended by "Q2_2008_Gliese_208" and "Q2_2008_111_Tauri". If errors occur later after having appended the records from "Q2_2008_Pi_Orionis", I want to know from which file the error records originated. Thanks!Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-04 : 13:51:15
|
When you say file, do you mean table?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-06-04 : 13:52:24
|
dude!!i reread your problem 4 times and i have no clue as to what you want.are you reffering to backups? with what do you generate the file?_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 13:54:57
|
Yes.....I mean table....please pardon me there, I'm having a senior moment.Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-06-04 : 14:02:21
|
table? huh? now i'm having a stupid moment once again from the top, sergeant!_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.0 out! |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-04 : 14:04:11
|
Just add a column to your mega table, TableName or similar, and add the value during the insert.INSERT INTO MegaTable(Column1, Column2, ..., TableName)SELECT Coumn1, Column2, ..., 'Q2_2008_Pi_Orionis'FROM Q2_2008_Pi_OrionisTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 14:10:03
|
I was thinking there'd be a more dynamic way to do this like: INSERT INTO MegaTable(Column1, Column2, ..., TableName)SELECT Coumn1, Column2, ..., TableName()FROM Q2_2008_Pi_OrionisSemper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-04 : 14:13:23
|
I don't know of any such built-in function, probably because how would it know which table to select from in a large query that joins tables together, unions result sets together, derived tables, ...?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Database maintenance routines:http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx |
 |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 14:49:35
|
Good point. Thanks....Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-06-04 : 15:50:28
|
Xerxes! Though I'm delighted to see you back I must say I'm a little dissapointed in your topic subject text.I would have expected something more creative. Oh well, I guess you're out of practice Be One with the OptimizerTG |
 |
|
Xerxes
Aged Yak Warrior
666 Posts |
Posted - 2008-06-04 : 17:55:08
|
I am indeed out of practice....but I'll have something much more creative later!Semper fi, XERXES, USMC(Ret.)------------------------------------------------------The Marine Corps taught me everything but SQL! |
 |
|
|