September 7, 2010 at 12:15 pm
--==== daily query to pull data from database to flat file
SELECT
V_APPT_BASIC.PERSON_ID, V_APPT_BASIC.FIRST_NAME, V_APPT_BASIC.LAST_NAME,
V_BU_BASIC.BU_CODE, V_BU_BASIC.BU_NAME,
V_BU_BASIC.BU_PARENT, V_BU_BASIC.BU_PARENT_NAME,
V_EMP_ALL.BIRTHDATE, V_EMP_ALL.GENDER
FROM database(databasename)
--===== create column(Columnname) to reflect in flat file even if not in database(databasename)
CREATE Column (A), pos(posid)
September 7, 2010 at 12:26 pm
Instead of trying to explain what you're looking for it would be more efficient if you would provide table def and sample data in a ready to use format as described in the first link in my signature together with your expected result.
Based on your description I have no idea what you're looking for (except the need for a flat file...).
September 7, 2010 at 1:07 pm
Thanks for your prompt response. I updated my question with what I'm trying to do. Here it is:
--==== daily query to pull data from database to flat file
SELECT
V_APPT_BASIC.PERSON_ID, V_APPT_BASIC.FIRST_NAME, V_APPT_BASIC.LAST_NAME,
V_BU_BASIC.BU_CODE, V_BU_BASIC.BU_NAME,
V_BU_BASIC.BU_PARENT, V_BU_BASIC.BU_PARENT_NAME,
V_EMP_ALL.BIRTHDATE, V_EMP_ALL.GENDER
FROM database(databasename)
--===== create column(Columnname) to reflect in flat file even if not in database(databasename)
create Column (A), pos(posid)
Thanks for your help.
September 7, 2010 at 1:19 pm
What exactly do you want to achieve with your approach? It's still not clear.
Again, please read and follow the instructions given in the article referenced as the first link in my signature.
As a side note: If you alter your table and add a column but don't include it in your select statement you won't see that column in the flat file either. Especially, if you don't add the logic to populate the columns with some values...
Edit: typo corrected
September 7, 2010 at 1:29 pm
Thanks for your response. I'm trying to make all the employees active in the output in flat file thereby writing a query to create a separate column with A as it's value so that beside every employee info there will be a column for A (Active).
September 7, 2010 at 1:32 pm
Also, I'm not allowed to update,alter any table in the master database from which the data is pulled. I hope you can help me.
September 7, 2010 at 1:36 pm
As stated before:
Please read and follow the instructions given in the article referenced as the first link in my signature ("How to get fast answers to your question").
You need to help us help you. well, you don't need to. But you should...
September 7, 2010 at 1:39 pm
Here is the an example of the end result:
Last name first name Status
Doe John A
September 7, 2010 at 1:46 pm
mashikoo (9/7/2010)
Here is the an example of the end result:Last name first name Status
Doe John A
You really don't like to read the article, do you?
How about adding ,'A' AS Status
to your query?
It won't give you the posid column as requested in an earlier post but your requirements may have changed in between...
September 7, 2010 at 2:18 pm
Mashikoo,
First, please read the article that Lutz has indicated in his signature block (you'll also find it the first article I reference below in my signature block). Following the instructions in that article, plus providing the expected results will get you the help you seek.
Second, how are you creating the flat file?
Third, the following may help, replace the '*' with the columns you need from your table (sorry, typing this on my BlackBerry so I am doing this on the fly):
select
*, -- replace with your columns
'A' as Active
from
dbo.yourtable -- replace with your table name
September 7, 2010 at 2:30 pm
Thanks Lynn,
But there is no column 'A' for active in the dbo.tablename, that is where my problem lies I need to write a new query refrencing this.
Thanks Lynn
September 7, 2010 at 2:39 pm
As Lutz suggested, if you just add the static value of 'A' to your SELECT, it'll show up on every record, and they'll all look active. That may or may not be helpful.
In my experience, if you tell these guys what you're *trying* to do, (more than?) half the time they'll have a better way than whatever you (or I) are currently doing. And if you supply them the data they need from that article they're trying to get you to read, they'll give you a solution that they've tested already to make sure it works.
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
September 7, 2010 at 2:59 pm
mashikoo (9/7/2010)
Thanks Lynn,But there is no column 'A' for active in the dbo.tablename, that is where my problem lies I need to write a new query refrencing this.
Thanks Lynn
First, did you try the query I suggested or did you simply dismisss it out of hand since you don't have a column named 'A'?
By the the way, the 'A' in my query is a literal value, not a column name.
Perhaps you should take the time to read about the SELECT statement in Books Online as well as the article Lutz and I have asked you to read.
September 7, 2010 at 3:06 pm
Hi Lynn,
I didn't dismiss your query. I will run it and let you know the outcome. I appreciate your effort.
Regards
September 7, 2010 at 3:07 pm
mashikoo (9/7/2010)
Thanks Lynn,But there is no column 'A' for active in the dbo.tablename, that is where my problem lies I need to write a new query refrencing this.
Thanks Lynn
mashikoo,
We understand that you don't have a status column, or a column A in your master table.
From what we understand, when you create the flat file, you want to add a status column, and you want every value to be the literal 'A'. Is this correct?
This is what has been suggested to you, on several occasions.
Tell you what. Just run the following code and see what it does:
SELECT 'I need to read BOL for more information on the SELECT statement'
FROM sys.databases
Do you see how EVERY record has this literal text? Well, that's what Lutz and Lynn have been trying to get you to try.
(You might also notice that Lutz, Lynn, Jon and myself all have the same first link in our signature. We do it for a reason - if you will actually read it, and follow it's advice, we will be able to help you out better. So, please, HELP US HELP YOU! Read the article, and follow it.)
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
Viewing 15 posts - 1 through 15 (of 21 total)
You must be logged in to reply to this topic. Login to reply