Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Putting File Name into a column within the file

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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-04 : 13:51:15
When you say file, do you mean table?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

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!
Go to Top of Page

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 1980
Blog: http://weblogs.sqlteam.com/mladenp
Speed up SSMS development: www.ssmstoolspack.com <- version 1.0 out!
Go to Top of Page

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_Orionis

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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_Orionis


Semper fi,
XERXES, USMC(Ret.)
------------------------------------------------------
The Marine Corps taught me everything but SQL!
Go to Top of Page

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 Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

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!
Go to Top of Page

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 Optimizer
TG
Go to Top of Page

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!
Go to Top of Page
   

- Advertisement -