How To Create Two Separate Fields From The Data?

Aug 2, 2007

Can anyone please help me with the following:


I have a table which has fields called defid, datavalue, pid etc.
I have to create a new table which should have fields:
CustID, datavalue[SocSec]{note:this is the value in d.datavalue when defid is 1004), datavalue[FirstName]{note: this is the value in d.datavalue when defid is 1006}, datavalue[LastName]{note: this is the value in d.datavalue when defid is 1007}, [FullName] {note: this is the value I should get by joining the datavalues (lastname and firstname) when defifis 1006 and 1007) ie. ex: FirstNameLastName.

COULD ANYONE PLEASE HELP ME ON THIS. DATA QUERY is as follows:
Thank you in advance.

SELECT DISTINCT c.CustID, d.datavalue, f.name
FROM dbo.Customers c
INNER JOIN dbo.Date7 d ON d.pid = c.root
INNER JOIN dbo.fielddisc f ON f.defid = d.defid
WHERE c.separatedate BETWEEN @StartDate AND @EndDate
AND c.DateTab = 7 AND d.defid IN (1004, 1006, 1007, 1009) AND c.CustID = 10 AND c.root = 8472
ORDER BY c.root

View 3 Replies


ADVERTISEMENT

TSQL - Trim String Containing Both Data And Value Into 2 Separate Data Fields

Aug 20, 2007

Hi!
Need help with this one:
I have a column with a string composed by several data. After using REPLACE several times, I get something like the data below, which has (in most of cases) a value and a date.








378 9/05

388 9/05

4/05

1/06 606

1/06 646

76 5/05

100 1/05

118 8/05

129 8/05

9/05 342

05/3 123

1/07

4/06 164
The problem is that I need to get each value alone (to separate columns), in example:
Value Date
378 09/2005
388 09/2005
0 04/2005
...
606 01/2006

and so on...
In addittion you can see that sometimes the Value come first or alone, and sometimes the Date come first or alone.

I will appreciate any good ideas,
Thanks in advance,
Aldo.


View 3 Replies View Related

Separate Fields Into Rows

Sep 18, 2006

I have a table with accountid and labtype
However inside of the labtype is data separated by semicolons like below

GIV;APS;LSL. What would be the best way to return this data as multiple rows such as

acctid lab
100 GIV
100 APS
100 LSL

Thee may be from 1-10 values in the labtype field

View 1 Replies View Related

BETWEEN With Date/Time In Separate Fields

Apr 22, 2008

My group is working on a project for school and neither of us have much experience with SQL or ASP. We are pretty much just writing an SQL query to get the data in a certain date range and using ASP to write the tables with the data in it.

Our problem is the SQL database has separate fields for date and time. There is nothing we can do about this because the VB.NET program that populates the tables automatically does this. We can't figure out how to do the BETWEEN statement when they are separate fields. We can do it for a date range and it works fine. An example of what we want to do is show the data from 11:00 am on 04/01/2008 until 4:00pm 04/03/2008.

Does anyone have any idea what we can do? I really want to learn this but it's frustrating because we can't seem to get much help at school.

View 5 Replies View Related

Separate Dropdown List Selectedvalue Into Two Fields

Aug 1, 2006

i have two columns in a "release" table that i concatenate on my aspx page into one value for my dropdown list.  for example, my database columns might look likeMajor: 3 | 3 | 4 | 4 | 5Minor: 1 | 2 | 1 | 2 | 1and my drop down list text like3.1 | 3.2 | 4.1 | 4.2 | 5.1my question comes when trying to take the drop down list's selected value and splitting it back into two fields so that i can use it for another query.  how can i split my "major" and "minor" version numbers back up so that i can run a query similar to:SELECT * FROM [Version] WHERE (([Major] = @Major) AND ([Minor] = @Minor))but only having the one parameter of: <asp:ControlParameter ControlID="ddlVersion" Name="Version" PropertyName="Text" Type="String" /> where the selected value has a string of "<major>.<minor>" (where the numbers are separated by a period)?

View 6 Replies View Related

Transact SQL :: Get Check Time From Separate Fields

Oct 14, 2015

I am using aloha POS and they have the date for every check in separate fields and now I want to calculate the total time for the checks but unable to get the how of it..

The date is DOB and it's datetime but I just need to extra the getdate() from it.The open time is OPENHOUR and OPENMINThe close time is CLOSEHOUR and CLOSEMIN

so basically the open time for the check will be the DATE FROM DOB + OPENHOUR + OPENMIN

And the close time will be DATE FROM DOB + CLOSEHOUR + CLOSEMIN

How can I get the total minutes for the check?

View 2 Replies View Related

How To Separate The DateTime Field Into Two Fields In View

Jun 21, 2006

Hi ,

I've a DateTime field in a table and I want to separate it into two fields in an SQL Server 2005 view one for Date and the other for Time so What is the function I can use to do this process?

Best Regards,

View 4 Replies View Related

SQL Server Admin 2014 :: Separate Max Fields From The Others To Another Filegroup?

Jan 18, 2015

we have many max fields in our database .

A role in performance says : It's better to separate this fields to another FileGroup with separate file.

Is the result good for performance? and what are the risks?

View 9 Replies View Related

Combine Separate Date && Time Fields Into One Datetime Field?

Dec 26, 2006

Good morning.I am importing an XLS file into one of my tables. The fields are:Date Id Time IO12/22/2006 2 12:48:45 PM 912/22/2006 16 5:40:55 AM 112/22/2006 16 12:03:59 PM 2When I do the import, I get the following:Date Id Time IO12/22/2006 12:00:00AM 2 12/30/1899 12:48:45 PM 212/22/2006 12:00:00AM 16 12/30/1899 5:40:55 AM 112/22/2006 12:00:00AM 16 12/30/1899 12:03:59 PM 2Here are my doubts:1. Would it be better to combine the Date & Time fields into onecolumn? If so, how?2. What issues or problems might I have when I program SQL reports, ifI leave the fields as they are?Any comments or suggestions will be very much welcomed.Cheers mates.

View 2 Replies View Related

Combine Separate Date &&amp; Time Fields Into One Datetime Field?

Dec 26, 2006

Good morning.

I am importing an XLS file into one of my tables. The fields are:

Date Id Time IO







12/22/2006
2
12:48:45 PM
9


12/22/2006
16
5:40:55 AM
1


12/22/2006
16
12:03:59 PM
2


When I do the import, I get the following:

Date Id Time IO
12/22/2006 12:00:00AM 2 12/30/1899 12:48:45 PM 2
12/22/2006 12:00:00AM 16 12/30/1899 5:40:55 AM 1
12/22/2006 12:00:00AM 16 12/30/1899 12:03:59 PM 2

Here are my doubts:

1. Is it be better to combine the Date & Time fields into one column? Advantages/Disadvantages?
2. If I don't combine them, should I use varchar or datetime data type?
2. What issues or problems might I have when I program SQL reports, if I leave the fields as they are?

Any comments or suggestions will be very much welcomed.

Cheers mates.

View 3 Replies View Related

T-SQL (SS2K8) :: Create Separate MS Excel Files By Looping Through Large Table

Jun 24, 2014

I have a master table containing details of over 800000 surveys made up of approximately 400 distinct document names and versions. Each document can have as few as 10 questions but as many as 150. Each question represents one row.

My challenge is to create a separate spreadsheet for each of the 400 distinct document names and versions containing all the rows and columns present in the master table. The largest number of rows would be around 150 and therefore each spreadsheet will not be very big.

e.g. in my sample data below, i will need to create individual Excel files named as follows . . .
"Document1Version1.xlsx" containing all the column names and 6 rows for the 6 questions relating to Document 1 version 1
"Document1Version2.xlsx" containing all the column names and 8 rows for the 8 questions relating to Document 1 version 2
"Document2Version1.xlsx" containing all the column names and 4 rows for the 4 questions relating to Document 2 version 1

I assume that one of the first things is to create a lookup of the distinct document names and versions assign some variables and then use this lookup to loop through and sequentially filter the master table data ready for creating the individual Excel files.

--CREATE TEMP TABLE FOR EXAMPLE

IF OBJECT_ID('tempdb..#excelTest') IS NOT NULL DROP TABLE #excelTest
CREATE TABLE #excelTest (
[rowID] [nvarchar](10) NULL,
[docName] [nvarchar](50) NULL,

[Code] .....

--Output

rowIDdocNamedocVersionquestionblankField
1document11q1NULL
2document11q2NULL
3document11q3NULL
4document11q4NULL
5document11q5NULL
6document11q6NULL

[Code] .....

View 9 Replies View Related

Subreports: Parameter Value Dropdown Shows Sum And Count Fields But Not The Actual Data Fields.

Jan 28, 2008


I have just started using SQL Server reporting services and am stuck with creating subreports.

I have a added a sub report to the main report. When I right click on the sub report, go to properties -> Parameters, and click on the dropdown for Parameter Value, I see all Sum and Count fields but not the data fields.

For example, In the dropdownlist for the Parameter value, I see Sum(Fields!TASK_ID.Value, "AppTest"), Count(Fields!TASK_NAME.Value, "CammpTest") but not Fields!TASK_NAME.Value, Fields!TASK_ID.Value which are the fields retrieved from the dataset assigned to the subreport.

When I manually change the parameter value to Fields!TASK_ID.Value, and try to preview the report, I get Error: Subreport could not be shown. I have no idea what the underlying issue is but am guessing that it's because the field - Fields!TASK_ID.Value is not in the dropdown but am trying to link the main report and sub report with this field.

Am I missing something here? Any help is appreciated.

Thanks,
Sirisha

View 3 Replies View Related

Add 2 Separate Columns From Separate Tables Using Trigger

Feb 15, 2012

I am trying to add 2 separate columns from separate tables i.e column1 should be added to column 2 when inserted and I want to use a trigger but i don't know the syntax to use...

View 14 Replies View Related

Display Output On Separate Separate Line

Feb 10, 2007

How can i format my query so that each piece of data appears on a new separate line? Is there a command for a new line feed? does not work.

thanks.

For example:

a: data
b: data
c: data

a: data
b: data
c: data

View 6 Replies View Related

Separate Data

Aug 18, 2005

Hi guys,

How can I separate the data that is alpha numeric in type?


FloorNumber

8A
8B
8C
11A
11B
12
13
14
15A


I need to separate the 8 from A in 2 columns just like ....

UnitLevel UnitCode
8 A
8 B

And if the floor numbers do not have "letters" then let it be.

Thanks.

View 2 Replies View Related

Combined 2 Data And Separate Them

May 26, 2005

I have a data grid with dropdownlist.the dropdownlist is populated with datas wth a sql statement with 2 combined datamy sql : SELECT NAME + CAST(ID as CHAR(10)) FROM TABLE1When i select a value from the dropdownlist, i need to separate the data, name and id into different columnshow do i do it?Is there a way to manipulate the sql to do such a thing?

View 1 Replies View Related

Separate Data In One Field

Feb 28, 2002

I recieved a SQL Server table that was supposed to have just the firstname in a field, but actually has firstname and middle name.
Example David Michael
Carol Anne
Is there a way in a query to look for the blank space and separate the names?

View 2 Replies View Related

Does RDA Create New Fields?

Nov 20, 2007

Hi!
I need to sync an application on windows mobile 5 that uses sql server mobile with sql server 2005. I've tried Merge and it populated the tables on the server with new fields and triggers. Does RDA do the same thing?

Jesus saves. But Gretzky slaps in the rebound.

View 2 Replies View Related

Take Data, Write Down, And Separate With A , (comma)

Feb 5, 2008

Hello there,How can i take data out of my database, put them into a textbox and then separate with a comma..An example:----------------------------------| column Email           || mail1@email.com     || mail2@email.com     || mail3@email.com     |----------------------------------Put them into a textbox and separate with a , (comma)-------------------------------------------------------------------------------------| mail1@email.com, mail2@email.com, mail3@email.com |-------------------------------------------------------------------------------------Anybody who know how I can do that? :S

View 4 Replies View Related

How To Separate Data&#39;s And Log&#39;s Files Location.

Sep 26, 2000

Hi everybody,

On the time of installation SQL Server asking me where I wont to locate the DATA files and the PROGRAM files. It’s giving to me choice to put database AND log files on one disk and program files on separate. But what about to separate LOG and DATA files. I have RAID1 especially created on F: drive for LOG files and RAID 5 on E: for DATABASE files. When I have to separate that if not on the time of installation? How I can do that?

Thanks,
Miriam

View 3 Replies View Related

Concatenating Data From Separate Rows

Jul 23, 2013

Ok, I have three tables worth of data. They basically hold data that is keyed into a system for potential clients and include stuff like names, weights, classes of weight, addresses etc.

The main table that holds data on a record by record basis is set up like this:

Tbl_prospect
Prospect_id (PK, unique)
Prospect_batch_id(unique)
Prospect_record_num
Client_code

This table contains the batches (or collections of the data above). Basically a collection of bills is called a batch, so if a batch has 18 bills in it, those 18 bills are keyed and assigned the prospect_batch_id above.

Tbl_prospect_batch
Prospect_batch_id (PK, unique)
Prospect_batch_num

This is the table that contains the various weights and classes for the individual records in the first table (tbl_prospect):

Tbl_prospect_clwt
Prospect_clwt_id (pk, unique)
Prospect_id(unique)
Class
weight

Generally without worrying about the multiple classes and weights it's easy to just join all three tables and pull the fields I need, but now that I have to get multiple classes and weights I have no clue how to actually grab them and delimit them with a comma.

I think I'm only going to be working on tbl_prospect and tbl_prospect_clwt, and if I put a filter in place for the prospect_batch_id I can see the individual record in tbl_prospect as well as the multiple classes and weights in the clwt table, as seen here:

So record 18 of that batch is comprised of two shipments, one that is class 100/weight 1623 and one that is class 70/weight 438, just not sure how to actually grab both of those for each record and delimit them.

View 5 Replies View Related

Separate Data Stuff From Applications

Jan 22, 2007



Hi,

This is probably for most of you a very basic question. My goal is to define in a seperate instance from application all infos related to DataSets and DataAdapters that are needed when connecting to a specific database. Why?

First, I would like to be able to have in a single instance everything needed when hooking to a SQL Server Express database and in an other everything needed when hooking to a SQL Server CE database. Then, from application, I would like to be able following a few basic configuration steps to choose from one or the other, or even both in specific cases.

Second, I want to be able to seperate Database related stuff from application so that I can re-use everything from any other application when needed.

I've read several books, articles on the subject and would like to have your opinion as several approaches were illustrated through them. What would you use for this:

- Component class?

- Class library?

- or else?

Any good articles on the subject?



Thanks in advance for sharing,

Stéphane

View 3 Replies View Related

Create Table And Fields

Jan 13, 2007

I have maked this little code but dont know the way to insertt new table and fileds in database DATABASE01...


Private Sub Command1_Click()

Dim objConn As ADODB.Connection
Set objConn = New ADODB.Connection
objConn.ConnectionString = "driver={SQL Server};server=DVD377-14D9E48CSQLEXPRESS;uid=;pwd=;database=master"
objConn.Open
objConn.Execute "CREATE DATABASE DATABASE01"

''''''''''''''''''
'"CREATE table Mytable"
''''''''''''''''''

''''''''''''''''''
'"CREATE filed1" in text format
'"CREATE filed2" in text format
'"CREATE filed3" in text format
'"CREATE filed4" in date format(DD/MM/YYYY)

''''''''''''''''''

objConn.Close

End Sub

View 1 Replies View Related

Does RDA Create Extra Fields?

Nov 20, 2007

Hi!
I need to sync an application on windows mobile 5 that uses sql server mobile with sql server 2005. I've tried Merge and it populated the tables on the server with new fields and triggers. Does RDA do the same thing?

Jesus saves. But Gretzky slaps in the rebound.

View 4 Replies View Related

Update Fields With Data From Other Fields In Same Row

Jun 30, 2000

Pardon me if this question is too elementary. I am trying to create a trigger that will cause certain datafields to be updated with values from other data fields in the same row when a certain column, created specifically to fire the trigger, is updated. The purpose of this is to reduce data entry by field personnel.I think I have the create trigger statement correct, but I'm a little confused on the update statement.

In a nutshell, how can I write something like:
UPDATE "TABLENAME"
SET DATAFIELD1 = DATAFIELD2
WHERE RECORDNUMBER = (THE SAME RECORD NUMBER)

I do know that I have to ensure that sp_dboption Recursive Triggers value is set to false, thanks.

View 2 Replies View Related

How To Send And Receive Data, Between Two Separate Computer?

Jul 23, 2005

hi alli have a web application on a web server.and another windows application on another computer.there are databases on each of them.how can i send and receive data between these two applications?please reply me as soon as possibleregards

View 5 Replies View Related

Install Logs And Data On Separate Arrays

Aug 14, 2006

I'm getting ready to install SQL Server 2005 Enterprise for the first time and I have a question about the directory location of the log files and the data files. I have 3 RAID arrays on my server, 1 for the OS, 1 for SQL Logs, and 1 for SQL Data.

Here's my issue. I want to install the logs on the Log array and the SQL data on the SQL data array, however, during the installation I can't find anything that allows me to select certain directories!


Am I missing something somewhere?

Thanks

View 3 Replies View Related

Can't Create A Foreign Key Using Non_primary Key Fields

Aug 9, 2004

Howdy all !
I'm just a bit on the frustrated side cause I want to create a foreign key but SQL Server won't let me. :(

I have table A with a primary key of main_id
I have table B with a primary key of another_id

Table A has a corresponding field called another_id.

I'm trying to create a foreign key between Table A & Table B on another_id but since it's not the Primary Key in Table A I get the following error:

There are no primary or candidate keys in the referenced table 'A' that match the referencing column list in the foreign key 'fk_classB_classA'.

Am I missing something totally obvious here? Why should I have to create a foreign key on a primary key?

What I find interesting is that I can create the relationship from enterprise manager but when I script it out is when I run into problems.

Here's the script I'm using:

Begin Code

alter table B add
constraint fk_classB_classA foreign key
(classB) references A (classB)
on delete no action
on update no action

End Code

Any help is greatly appreciated.

tam

View 6 Replies View Related

Create A Link Between Fields Of Two Tables

Jan 24, 2007

Amir writes "Dear Team Members;

Im writing a program in ASP language which it is using SQL Server for database.

I want to know how to create a link between fields of two tables. For example:
I have a table named: Projects containing:
p_name
status
date
member1
member2

and another table named results containing:
p_name
s_status
status1
status2

I want to create a link between field s_status of STATUS table and field status of table Projects

Users are sending data to table projects, when a user send some data to status of projects, I want this link to send data from status in project to s_status of results.

Could you please help me how to do it?

Regards.
Amir Zandi"

View 1 Replies View Related

Create Table,fields Come From Csv File

Oct 24, 2006

I want to create a table automatically,and fields come from a csv file

any idea? TIA

View 1 Replies View Related

Join Several Fields To Create New Field

Oct 4, 2006

What would be the recommendation/approach in creating a seperate field in which joins several differate fields together.



I have a table with field name a, b, and c. I want the information in those fields to be populated in a seperate field, d.



So instead of:



a

122

b

joe

c

st



I would have:

d

122 joe st



Thanks!

View 12 Replies View Related

Integration Services :: Purge Data In Transaction Table Or Delete Some Data And Store In Separate Table

Aug 18, 2015

How to purge data  in transaction table or we can delete some data and store in separate table in data warehouse?

View 7 Replies View Related

Splitting One Data Field With Hyphens To Separate Records

Feb 16, 2004

I receive a file that will have hyphens between data items such as
123-aed-edr-45r-ui9
1-ed3-45r-rrr-98u
I need to split the values to load into a table that will hold the 5 separate data itens. The fields will always have the hyphens but could be different lengths. Any idea on a best approach to split this in tsql

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved