February 8, 2008 at 3:23 am
Hi,
Can you tell me how can i get table(s) name from one column name that give me to put in a query?
The point is:
- They give me the following column name (OfferExternalID) and i need to join this query in one query but i don't know how can i get table name associated with this column. :blush:
One other question, how can i send the output of one date in the following format (DD/MM/YYYY)? :sick:
Thanks and regards
JMSM
February 8, 2008 at 3:36 am
JMSM (2/8/2008)
Hi,Can you tell me how can i get table(s) name from one column name that give me to put in a query?
The point is:
- They give me the following column name (OfferExternalID) and i need to join this query in one query but i don't know how can i get table name associated with this column. :blush:
One other question, how can i send the output of one date in the following format (DD/MM/YYYY)? :sick:
Thanks and regards
JMSM
The answer to your first question is that you can look at the sys.columns and sys.objects system views (I assume you are on SQL Server 2005)
So in your case just see the result of the query:
SELECT sch.name AS ParentSchema
, so.name AS ParentName
FROM sys.columns AS sc
JOIN sys.objects AS so ON sc.object_id = so.object_id
JOIN sys.schemas AS sch ON sch.schema_id = so.schema_id
WHERE sc.name = 'OfferExternalID'
Regards,
Andras
February 8, 2008 at 3:37 am
Hi
select object_name(object_id),* from sys.columns where
name = 'OfferExternalID' -- put the column here.
you can use the Convert function for formatting the date.
"Keep Trying"
February 8, 2008 at 3:41 am
JMSM (2/8/2008)
Hi,...
One other question, how can i send the output of one date in the following format (DD/MM/YYYY)? :sick:
Thanks and regards
JMSM
Concerning your second question, you can use the style parameter of the convert function:
select convert( varchar, getdate(),103)
Will return:
08/02/2008
Regards,
Andras
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply