I have a table that has the first name and last name together in one field (stupid I know). I want to extract the first name from the field and copy it into another field names, well, firstname. I figure it might be possible since there is a comma after the last name. But how can I do this?
So for:
STRNAME ------------- adams, john ------------- washington, michael -------------
I want it to be like this
STRNAME | STRFIRSTNAME --------------------------- adams | john --------------------------- washington | michael
So I guess there would be two parts to the statement:
1. First I need to select or trim the strname field to the comma. BUT I don't want to just trim it- I want to copy it.
2. The next thing I need to do is to copy the lastname (the part that I trimmed) into a new field which I created called lastname.
I posted this a while ago with no luck and I'm going to try it again:
I have a column called strlastname with contains the firstname and last name of a client. I want to separate out the first name and last name into into two separate fields. I figured maybe I can do it easier if I copied the column into the table. So now I have a column called strfirstname that contains the first name and the last name and a colmn called strlastname that contains the first name and last name. The lastname is seperated from the first name with a comma like this:
I need to find rows from the above table which has the first occurence of the corresponding ID. This the output will contain the rows that will have first occurence of the following ids.
1067381, 1087668, 109754, 1103377.
How does one handle this. I have not been able to come up with the sql yet.
I have a package which establishes connection with DB2 server.I dont have any db2 application where i can format query for db2.This is my query in access/sql. can someone help me converting it into a db2 query.i tryed to google and use the functions but i failed and even the error that ssis gives don't help asthey are same for any type of error. Thanks in ADV
SELECT table1.YYYY & table1.MM as MO_YR, table2.CNTRYCD AS CNTRY_CD, Sum(table1.AMT) AS [VALUE] FROM table1 INNER JOIN table2 ON (table1.MM = table2.MM) AND (table1.YYYY = table2.YYYY) WHERE (table1.YYYY BETWEEN YEAR(DATE()) AND YEAR(DATEADD("m",-3,DATE()))) AND (table1.MM BETWEEN MONTH(DATE()) AND MONTH(DATEADD("m",-3,DATE()))) GROUP BY table2.CNTRYCD, table1.YYYY, table1.MM
I need to get some data from an enormous, creaky old SQL 6.5 database.I know nothing about either the data schema (though I believe some sortof documentation exists), nor 6.5 for that matter, having come to SQLServer at 7.0.My clients need the data in comma delimited format.Please, can anyone suggest any possibilities? One thing that occurredto me might be to create an Access application, use an ODBC link to theSQL DB, and then leverage Access' not inconsiderable functionality toget the data out.Does anyone foresee any problems with this, or any better ways?Forever in your debt.Edward--The reading group's reading group:http://www.bookgroup.org.uk
'm trying to get the value from a column in a SQL Server table that contains XML but the type of the column is not XML it is TEXT.
I tried this:
SELECT [Id], [Request] FROM [Tracker] WHERE [Request].value('/Credit[1]/Loan[1]/LoanApp[1]/Applicant[1]/Personal[1]/Individals[1]/Individual[1]/GivenName[1]/FirstName[1]', 'nvarchar(50)') = 'Tom'
but I get this error :
Cannot find either column "Request" or the user-defined function or aggregate "Request.value", or the name is ambiguous.
I tried to cast the column like this:
select CAST(CAST(Request AS NTEXT) AS XML).value('(/Credit[1]/Loan[1]/LoanApp[1]/Applicant[1]/Personal[1]/Individuals[1]/Individual[1]/GivenName[1]/FirstName[1]', 'nvarchar(50)')
from Tracker but with this I get this error:
XML parsing: line 1, character 15, A string literal was expected
hii all i am havie a database with given fileds like projectid,projectcode,projectname,startdat,enddate,etc.... my problem is to show all months and year between each projects startdate and enddate in a datagrd..and the table dont have month, year field.. i need to use sql quiery.. if anybody can help me in this matter.. it will be greatful.. thanks in advance..binoy
Hi, I'm hoping someone has an idea or two on this topic. Basically I have three tables of data say tContact, tQuestion, tAnswer
tContact ----------- ContactID Email Name
tQuestion ------------ QuestionID Question
tAnswer ------------ QuestionID ContactID Answer
I need to extract the data for the client and they would like to see the data with one line per contact, but showing every answer to every question... they would like the data formatted like this:
Obviously to get the data I cansimply do an outerjoin to get all contact data then all questions, and answers that exist... but that will obviously return tabular data with one row per each answer... Does anyone have any ideas on how to do this using just SQL? I can pull the data and write a function that spits it out to text using the Stringbuilder class and some logic, but I'm thinking this must be possible in SQL natively... any help would be more than appreciated. Thanks in advance.
Lets say I have a column of type varchar and need to extract an integer value from the middle of it. The string looks like this:'this part is always the same' + integer of varying length + 'this part is different but always the same length'Is there a way to trim the constant string lengths from the beginning and end?
Hi,I'm using MSSQL2k and I have some customers in a customer table. I want to write a webapp and offer them the possibility to teach them using the app while having telephone contact with them. They can use the app on my server for some time and add data to it.After a while when someone wants to buy the app I would like to distribute the app as an Intranet app to their own server and let them have the data they already have wrote into the db on my server.Because there will be some customers with much data I'd like some guidance in how to plan the database to easily extract their own data and create a new db polutated with their data.Kenneth
Hi, I'm inserting records into a Table1 with the following fields : tabID int 4ClientID int 4..etc etc. In the insertitem template, I want the user to enter a Clientcode into textbox1. Then I want that client code validated against a lookup table, ClientTable and if valid, get the ClientId value from that ClientTable, so that I can populate the ClientID field in Table1. I've got a mental block and I cannot see how I can do that ! Any ideas most gratefully appreciated. Thanks Sunil
As I can extract the hour values and minute of a field of type datetime to compare it with the values of a field of type smalldatetime of another table
Hi i have a query select 12 * int( "SQLUSER"."BTT120".yyyy) + int("SQLUSER"."BTT120".mm) as actual, 12*year(CURRENT DATE) + month(CURRENT DATE) as ending, 12*year(CURRENT DATE) + month(CURRENT DATE)-3 as starting from "SQLUSER"."BTT120" where "SQLUSER"."BTT120".yyyy ='2007' and "SQLUSER"."BTT120".mm in ('10','11','12')
which gives me ourput
Actual ending Starting 24094 24097 24094
My actual requirment is to get the data for the rolling 3 months for which i used the same logic as above in the WHERE clause.
SELECT "SQLUSER"."BTT120".YYYY CONCAT "SQLUSER"."BTT120".MM AS MO_YR FROM "SQLUSER"."BTT120" where (12 * int( "SQLUSER"."BTT120".yyyy)) + int("SQLUSER"."BTT120".mm) between (12*year(CURRENT DATE)) + month(CURRENT DATE)-3 and (12*year(CURRENT DATE)) + month(CURRENT DATE)
everything looks good but iam not getting output, there is data for the date range
"Current Date updated ( 12/31/2015 -> 12/31/2016 )" "Status updated ( Open -> Should be Closed )" From example 1 ==> need outputs of " 12/13/2015" and "12/31/2016"; example 2 --> need outputs of "Open" and "Should be Closed"
These are what all records look like:
1. It contains the word, "updated". 2. There is a space after the last character of updated. Then, there is a space before open parenthesis. Then, there is a space before getting the required word. Example: "updated ( xxxxx" (xxxxx is a required extract word.) 3. The entire word(s) should be captured before the "->" sign (after the open parenthesis) 4. The last part is to captured everything after the "->" but before the close parenthesis ")"
What would the syntax be to insert a column to the right of this one, and extract the first 8 digits from the data in the DATEID column and insert that into the new column DATE, therefore making it easier for me to query against an actual date?
I have a long text in 'Quote' column as below and i have to extract Trip Duration, Destination and Base Rate from this text. The ‘Base Rate’ will be repeated throughout the text if there is more than one traveler and I only need the first instance.
Begin Quote Calculation<br /> <br />....<br /> Agent Id: 001<br /> Trip Duration: 5days<br /> Relationship Type: Individual<br />....nDestination: AreaTwo<br /> <br ...../>Resolved Trip Type To: 1 with Trip Subtype: 0<br /> Resolved Relationship: Individual....... /> *Base Rates*<br /> Base Rate: 6.070000<br />.....Resolved Trip Type To: 2 with Trip Subtype: 0<br /> Resolved Relationship: Individual....... /> *Base Rates*<br /> Base Rate: 9.070000<br />.....
Result
Trip Duration: 5 days Destination: AreaTwo Base Rate: 6.070000
is it possible to extract from Oracle, transform (preferably in the buffer) and load data into a Oracle db using SSIS? is there any white paper/ article on the process?
Hello Friends, I need suggestion/help I have to build a package using SSIS and the requirement is like this, First I have to check the data source type(3 types for now) then I have to select a query for each different source from a table (basically the connection string and query changes for each query) and load the data into the dimension and fact tables.
I am not able to get the full picture of how I am going to achieve this, there is little complication to this one of the 3 sources has 15 servers from where i have to extract data Hope I am clear enough