Any Ideas On How To Combine Records Into One

Mar 25, 2004

Here is what I have,

select id, name from rss_user

gives me this

r604738 one
r604738 two
r604738 three
r604739 one
r604739 two
r604739 three
r604739 four

I would like to be able to pipe this into a @temp table so it looks like this,

r604738 one,two,three
r604739 one,two,three,four


Any ideas, so far I am drawing a blank.

View 1 Replies


ADVERTISEMENT

Combine SQL Records

Nov 8, 2007

I have a SQL table with Sales Order release information.

Following are some records from the table





SMIPartNo
QtyType
PO
POLine
QtyDue
UOM
DateDue

DateDueType
fsono
fcustno

finumber
frelease
fspq

JI-117933A1
Firm
N40136001
234
200
EA
7/2/2007 0:00

SH Ship Date
E00001
20

001
1
1800

JI-117933A1
Firm
N40136001
234
400
EA
7/9/2007 0:00

SH Ship Date
E00001
20

001
2
1800

JI-117933A1
Firm
N40136001
234
400
EA
7/30/2007 0:00

SH Ship Date
E00001
20

001
3
180

If sum(QtyDue) is Less than fspq then read next record, if sum(QtyDue)>= fspq then write the record.

For the above example the output would look like the following






SMIPartNo
QtyType
PO
POLine
QtyDue
UOM
DateDue

DateDueType
fsono
fcustno

finumber
frelease
fspq

JI-117933A1
Firm
N40136001
234
1000
EA
7/2/2007 0:00

SH Ship Date
E00001
20

001
1
1800


Any help would be nice.

Thanks

David Davis

View 2 Replies View Related

Combine Two Table Records By First Name?

Feb 15, 2012

I have 2 tables First is Student_detail and another is Employee_detail. Student_detail have 14 fields like (stud_Firstname,stud_Lastname...) and Employee_detail have 17 fields like(emp_Firstname,emp_Lastname...).there is no relationship between these two table and also not in a relationship with any other table in my database.This is a structure of my db. but i want to get the records from these two table whose first name is same for both the tables.as well as the result of this query will first show me Student_detail record first and then Employee_detail record.but not in a one row.it should be display in one by one.

Like this way:

HTML Code:

Student_detail :-

stud_First_name stud_Last_name std_city ........
Shrikant Joshi Jalgaon ........
Yogesh Trivedi Malkapur ........

Employee_detail:-

emp_First_name emp_Last_name emp_city ..........
Tushar Patil Mumbai ..........
Shrikant Rane Nasik ..........

Result of a query:-
First_name Last_name City ..........
Shrikant Joshi Jalgaon .........
Shrikant Rane Nasik .........

View 14 Replies View Related

Combine Records On Two Fields

Nov 5, 2007

Hello everyone -
This is my first post to the forum and I'm very new to SQL. I apologize if this is addressed elsewhere.

Here is an example of the results I am getting from my query

AdmissionID, sNurseInit, sSWInit
100, {NULL}, SAE
100, REG , {Null}


Is there a way to combine (merge, join? I don't know the right word) these records so that a single record for the admission is returned?

AdmissionID, sNurseInit, sSWInit
100, REG, SAE


Thanks in advance!
Amy

View 20 Replies View Related

Combine 4 Tables Without Repetitive Records

Oct 29, 2006

How to write a sql to combine the 4 tables into one without repetitive records? The 4 tables have exactly the same fields.

The tables do not have primary key. The fields to identiry the rows is name and dob. In the case the name and dob is same for two records, the one with latest date_created is selected.


Thanks

View 9 Replies View Related

How To Combine Results From Multiple Records Into One

Apr 19, 2004

Hello,

I have a table which has the following structure:

ID MessageText
001 Hello
001 There
001 Working
003 See
003 you
003 Next
003 Time

How to build a query or store procedure to return result like this:

ID MessageText
001 Hello There Working
003 See you Next Time

Your help/advice is greatly appreciated.

Thanks, Ficisa

View 14 Replies View Related

Compile/combine The Contents Of Several Records.

Dec 5, 2005

I have the following table;CREATE TABLE [x_Note] ([x_NoteId] [int] IDENTITY (1, 1) NOT NULL ,[Note] [varchar] (7200) COLLATE SQL_Latin1_General_Pref_CP1_CI_AS NOTNULL ,CONSTRAINT [PK_x_NoteId] PRIMARY KEY CLUSTERED([x_NoteId],) WITH FILLFACTOR = 90 ON [USERDATA] ,) ON [USERDATA]GOMy clients want me to take the contents of the Note column for each rowand combine them. In other words, they basically want:Note = Note [accumulated from previous rows] + Char(13) [because theywant a carriage return] + Note [from current record].What is the most efficient and relatively painless way to do this? Ithink it might require a cursor, but I'm not sure if there is a moreelegant set-based method to make this happen.

View 14 Replies View Related

How To Combine 2 Records Into 1 Unique Record

Jul 11, 2006

Hi all,We have an app that uses SQL 2000. I am trying to track when a code field(selcode) is changed on an order which then causes a status field (status)to change. I tried a trigger but the app may use 2 different updatestatements to change these fields depending on what the user does. When thetrigger fires (on update to selcode), the status field has already beenchanged. So my trigger to record the changes from inserted and deleted donot get the true 'before' value of the status field.The app does use a log table that tracks these changes. The problem I amhaving is that 2 records are created, one for the change to selcode andanother for the change to status.I am looking for help with a script to combine the existence of these 2 logrecords into 1 unique record or occurance that I can track.example:ordlog: table that logs order changesordernr: order numbervarname: name of field being changedold_value: contents of field before changenew_value: contents of field after changesyscreated: date/time of log entrySELECT ordernr, varname, old_value, new_value, syscreatedFROM ordlogwhere varname = 'selcode' and ordernr = '10580'SELECT ordernr, varname, old_value, new_value, syscreatedFROM ordlogwhere varname = 'status' and ordernr = '10580' and old_value = 'A' andnew_value = 'O'So I need a way to combine these 2 log entries into a unique occurance. Theordernr and syscreated could be used to link records. syscreated alwaysappears to be the same for the 2 log entries down to the second. Selcodecan change from NULL to a number of different values or back to NULL.Statusis either 'A' for approved or 'O' for open. An order can have many logentries during its life. The selcode may be changed several times for thesame order.Ideally, I would like a result that links 2 log entries and shows the statuschanged from 'A' to 'O' when selcode changed.Thanks for your time.

View 1 Replies View Related

Combine Multiple Records Into Single Row

Mar 29, 2007

This is how the data is organized:vID Answer12 Satisfied12 Marketing12 Yes15 Dissatisfied15 Technology15 No32 Strongly Dissatisfied32 Marketing32 YesWhat I need to do is pull a recordset which each vID is a single rowand each of the answers is a different field in the row so it lookssomething like thisvID Answer1 Answer2 Answer312 Saitsfied Marketing Yesetc...I can't quite get my mind wrapped around this one.

View 13 Replies View Related

Simple Cursor To Combine Records

Sep 28, 2007



I need to return one record with concatenated string fields from a table that may contain several records. I think a cursor will be able to do what I want, but I'm not very experienced at writing them.

My data

HDR DMCD
107 TEX
107 AIR
107 LG
108 TEX
108 CAR
109 SM

I want the result of my query to find adn return each header and return the 1 or more DMCD field values concatenated. i.e.

107 TEX AIR LG
108 TEX CAR
109 SM



This is my attempt at the cursor so far


SET NOCOUNT ON

DECLARE @AACODE varchar(50),@hdr varchar(20),@dmcd varchar(20)

DECLARE AAROW_cursor CURSOR FOR

SELECT aaglhdrid,aatrxdimid

FROM aag30003



OPEN AAROW_cursor

FETCH NEXT FROM AAROW_cursor

INTo @hdr, @dmcd

WHILE @@FETCH_STATUS = 0

BEGIN

set @aacode=@aacode+@dmcd

select @hdr,@dim,@aacode



FETCH NEXT FROM aarow_cursor

INTO @hdr, @dmcd

END

CLOSE AAROW_cursor

DEALLOCATE aarow_cursor

View 5 Replies View Related

T-SQL (SS2K8) :: Query To Combine Records In A Single Row

Jun 5, 2014

I'm working on a report where my table is as follows:

WITH SampleData (ID,NAME,[VALUE]) AS
(
SELECT 170983,'DateToday','6/04/2014'
UNION ALL SELECT 170983,'DateToday','6/04/2014'
UNION ALL SELECT 170983,'employee','1010'
UNION ALL SELECT 170983,'employee','1010'

[Code] .....

Here is my query against the table above:

SELECT
ID
,MAX(CASE WHEN NAME = 'employee' THEN VALUE END) AS PERSON
,MAX(CASE WHEN NAME = 'DateToday' THEN VALUE END) AS REQUEST_DATE
,MAX(CASE WHEN NAME = 'LeaveStartDate' THEN VALUE END) AS REQUEST_START_DATE
,MAX(CASE WHEN NAME = 'LeaveEndDate' THEN VALUE END) AS REQUEST_END_DATE
,MAX(CASE WHEN NAME = 'HoursPerDay' THEN VALUE END) AS REQUESTED_HOURS
,MAX(CASE WHEN NAME = 'LeaveType' THEN VALUE END) AS REQUEST_TYPE

FROM SampleData

Here is the result from the above query, I'm not sure how to get the desired results (listed at the end):

IDPERSONREQUEST_DATEREQUEST_START_DATE REQUEST_END_DATE REQUESTED_HOURS REQUEST_TYPE
170983NULL6/04/2014NULL NULL NULL NULL
1709831010NULL NULL NULL NULL NULL
170983NULLNULL NULL NULL 8:00 NULL
170983NULLNULL NULL 6/16/2014 NULL NULL

[Code] .....

My Desired results are as follows:

IDPERSONREQUEST_DATEREQUEST_START_DATE REQUEST_END_DATE REQUESTED_HOURS REQUEST_TYPE
17098310106/04/20146/16/2014 6/16/2014 8:00 Personal
17102416/04/20146/17/2014 6/17/2014 8:00 Bereavement

View 2 Replies View Related

SQL Server 2014 :: Combine Records That Are Identical And SUM Values In Price Field

Sep 30, 2015

I have a robust query that returns a dataset and the data is good, however some of the records contain the exact same data with the exception of the 'Price' field. I want to combine the records that are identical and SUM the values in the 'Price' field. My query and example return dataset is below.

Query:
--------
select distinct
'On-Demand' as 'Business Line',
o.OrderID as 'Order #',
isnull(d.DisplayCode,'UNK') as Hub,
isnull(rz.RouteID,'UNK') as 'Default Route',
'On-Demand' as 'Assigned Route',

[Code] ....

View 4 Replies View Related

Any Ideas

Oct 29, 2004

I need for a database to give my users and indication that a renewal has been complete. Basically what happens is every year once a month a report is generated from sql of how many employees need their gaming license renewed the filter is based off of a field called final suit. I need to find a way to let them know through the database that an employee has been renewed. anyone got any ideas??

View 9 Replies View Related

Ideas Anyone

Apr 9, 2007

Hi all
I am fishing for ideas on the following scenario and hope someone can point me in the best direction.

I create a new table and insert data from relevant other tables but i want to set the data in the new table colums to set widths that have leading zeros where applicable.
I.E the new table column is varchar (10) the data going in to the column is coming from another table where the size was varchar (8) but the data was only 2 characters in size so i want to pad it out to the full new varchar (10) with leading zeros if that makes sence.

I am really just trying to get some ideas on the best possible way to do this thanks.

View 2 Replies View Related

Need Ideas

Nov 9, 2007

I have a table with 18,000 records with beg_eff_date since the year 2005. I need to separate the entries based on their daily activity. For example if Beg_eff_date 01/0/2005 then day is "1" if Beg_eff_date is 01/27/2005 then the day is "27".
Repeating the same process until I reach "NOW" present time. Any ideas of how can I do this?

Thank You for all your previous help and the current one!!

View 9 Replies View Related

Any Ideas

Nov 12, 2007

Hi:


I created a Temp Table that hold a collection of records by date.

I need to do create calculation that give me the Total fuel used per day:

c.rcpt_nom_vol -c.rcpt_fuel- c.rcpt_act_vol = Total Fuel used per day.
Then pull the result of this calculation and assign the result to the specific day of the month. For example is the Calculation Result is 4.25 on Feb 12, 2007. Then the record is insert into a Temp Table as 4.25 day #12.

Does anyone has an idea of how to do this? Thanks and Let me know!!!!





Create Table #TP_Daily_Imb(
contract_nbr char (8),
contract_sub_type char (3),
contract_type_code char (3),
current_expirtn_date datetime,
nom_id char(12),
nom_rev_nbr char(2),
beg_eff_date datetime,
rcpt_dlvry_ind float,
rcpt_nom_vol float,
rcpt_fuel float,
rcpt_act_vol float,
end_eff_date_DGC datetime)



SELECT Distinct a.contract_nbr, a.contract_sub_type, a.contract_type_code,a.current_expirtn_date,
b.nom_id, b.nom_rev_nbr,
c.beg_eff_date, c.rcpt_dlvry_ind, c.rcpt_nom_vol, c.rcpt_fuel,c.rcpt_act_vol
from TIES_Gathering.dbo.contract a
Inner Join TIES_Gathering.dbo.NOm b on a.contract_nbr = b.contract_nbr
Inner Join TIES_Gathering.dbo.Nom_vol_detail c on c.Nom_id = b.Nom_id
where (a.contract_sub_type = 'INT') and (a.Contract_type_code ='GTH')
and (DATEADD(mm, DATEDIFF(mm,0,getdate()), 0) < a.current_expirtn_date)
and (c.rcpt_dlvry_ind ='R')

View 9 Replies View Related

Looking For Ideas

Feb 5, 2007

Hi everyone
 
We've got currenlty around 500 dts 2000 in production.
 
In order to know in what ETL processes we have Oracle connections, or FTP tasks or whatever, we did a VB6 app using dtspkg.dll which load all the properties for each DTS into Sql server tables. So that, then you could see from a specific DTS how many connections, Sql Tasks it had and so on..
 
How to accomplish the same with SSIS? I know, doing the same but using .Net, of course, but is there any else approximation? I am little bit concerned when we will have hundreds of them up.
 
Maybe 2005 is offering this feature automatically, I don't know.
 
Thanks in advance for your time/advices/ideas,
 
 
 

View 1 Replies View Related

Ideas

Mar 1, 2008

Am working on an SSIS project and I am not sure how to handle this situation. I have four tables in two completely separate networks {AB} {CD} and I want to populate one of the tables D based on the information from tables A and C with the following scenario I get data from from table A make a lookup transformation to check what did has changed if the data has changed or if there is a new entry in table A get the identity key from table C {they both share a common field} and add the identity key as part of my data inserted in table D




A ----lookup <


data that has changed --- get the identity key from C ---- insert data from table A + identity key into D

View 5 Replies View Related

Looking For Ideas...

Mar 19, 2007

I have a text file that I am importing in a data flow task. Not all of the rows are the same, there are "header" rows that contain a company code.

What I want to do is keep that company code and append that to the row of text that I am writing to a CSV file.

Since you cannot change variables until the post execute, what are my options?

Hope that's clear

Thanks!

BobP

View 3 Replies View Related

Out Of Ideas

May 16, 2008



I have some performance issues which I can not explain; The database it is running on on a dedicated SQL server box with 8 cpu€™s 4 GB memory. Users are connecting with a fat client.

There is hardly on users using it but they are getting long delays. So I kicked of a profiler trace and sp_blocker. I noticed some queries taking over 30 sec to complete in profiler but when I run them in query analyzer they run in under a second.

I check the output from the blocker and there was no blocking over that time period and it was the only processes actually running.

How can it be so slow I have run out of ideas please any ideas would be welcome

Many thanks

View 7 Replies View Related

Looking For Process Ideas

Mar 9, 2007

I'm looking for Ideas on how to handle a Pldege Reminder process. For example; a pledge is made to pay $2400 over the next two years. They will pay $100 per month and each month a reminder will be sent. No real mistery if there is a balance you send a reminder. My problem is how to handle things like what if they want to pay quarterly or annually and how to determine if a payment is really due based on when they paid last, etc... You most likely see what I mean.
If anyone has done this in the past and/or has any ideas and is willing to share I would greatly appreciate any help.
Some stuff that may help you help me better:
tblClient (ClientID)
tblPledge (PledgeID, ClientID, PledegedAmt, PledgeDate,Frequency,NumberYears)
tblPledgePayments (PmtID, PledgeID,PmtAmt,PmtDate)

View 3 Replies View Related

Design Ideas

Jun 2, 2006

I'm new to asp.net. Please help me with some ideas about the design of databases and interface of the web site.
We are a public school district, I want to create a website for families to go on line to update their family and student's demographic information. Basically I put the students' infomation pulled from our student information system software on the web, the parents can log in on line to update it at the beginning of school year. After that, I will create some report and let secretary manually do the update to our student information system.
The demographic infor includes 3 parts,
1. family street address, city, state, zip2 guardian1 primary phones,second phone,  emails. primary phones,second phone3, student date birth, gender. may have multiple students in one family
But how can I track which field parents changed, shall I do it in programming in the web form, or later when I create some kind of reports. For I only want to pull students with the fields that updated and give them to secretary to update manully, and I don't want to generate a full report and let them compare which field is changed and then update, it will take them too much time.
Thanks much in advance

View 3 Replies View Related

DTS To Excel Out Of Ideas!

Apr 11, 2002

I've read thru all the threads here which say basically the same thing, use a drop table & then a create table to clear the spreadsheet. My problem is the process works the first time to create the table in a new Excel file but fails to clear excel after that. The processes drop, create, & pump data all work without fail but the spreadsheet data is appended to. I've used the wizard as well, saved the package and ran it again without success. Anyone ran into this one?

View 1 Replies View Related

Audit Log Ideas

Nov 28, 2000

I have tried to make my basic audit log do more, but i haven't gotten very far;

In my basic audit log, i record this information:

table
type of change
field modified
old value
new value
db user
date/time

This audit records everything, which is great, but it cannot relate information when i go back to analyze the changes; for example, when a "directory" record is added, a user's information may be entered into several different tables, such as:

name (different table)
addresses (different table)
phone numbers (different table)

If one wanted to look up the changes to addresses of a person in the directory based on the person's name, i could not do it with my existing audit log because the addresses would be in a different table than the name table and there is no relating data in the audit log to relate the address changes to a persons name;

What might be a solution? I have tried a few approaches and am at a loss;

Thank you!

--llyal

View 4 Replies View Related

Any Ideas On How To Speed Up This Sp?

Jan 18, 2006

it is working but takes about 3-4 seconds per exec.

CREATE PROCEDURE isp_ap_calc_apt_totals
@p_comp char(2),
@p_vend char(6),
@p_asofdatechar(8)
as

if (@p_asofdate <= '00000000')
begin
set @p_asofdate = '99999999'
end

delete from XAPAPTTOT
where xapt_comp = @p_comp and xapt_vend = @p_vend and xapt_asof_date = @p_asofdate

insert into XAPAPTTOT
select apph_comp, apph_vend, apph_type, apph_id, @p_asofdate,
sum(apph_paymnts),
sum(apph_discts),
sum(apph_adjts),
count(apph_paymnts),
sum(apph_paymnts)+ sum(apph_discts) + sum(apph_adjts) +
b.apt_gross,
0,
max(str(yy,4) + replace(str(mm,2),' ','0') + replace(str(dd,2),' ','0'))
from APPHISTF.a join APTRANF.b on b.apt_comp = a.apph_comp and b.apt_vend = a.apph_vend and b.apt_type = a.apph_type and b.apt_id = a.apph_id
where ((a.apph_comp = @p_comp) and (a.apph_vend = @p_vend) and (a.apph_unpost_dt = 0)
and (str(a.yy,4) + replace(str(a.mm,2),' ','0') + replace(str(a.dd,2),' ','0') <= @p_asofdate))
or ((a.apph_unpost_dt > 0 and a.apph_unpost_dt <= @p_asofdate and b.apt_unposted_fg = 1 and b.apt_comp = @p_comp and b.apt_vend = @p_vend and b.apt_type = a.apph_type and b.apt_id = a.apph_id))
or (((str(a.yy,4) + replace(str(a.mm,2),' ','0') + replace(str(a.dd,2),' ','0') <= @p_asofdate) and a.apph_unpost_dt > @p_asofdate and b.apt_comp = @p_comp and b.apt_vend = @p_vend and b.apt_type = a.apph_type and b.apt_id = a.apph_id))
group by apph_comp, apph_vend, apph_type, apph_id

update XAPAPTTOT
set xapt_last_payck =
(select max(apph_payck) from APPHISTF
where apph_comp = xapt_comp and apph_vend = xapt_vend and apph_type = xapt_type
and apph_id = xapt_id
and str(yy,4) + replace(str(mm,2),' ','0') + replace(str(dd,2),' ','0') = xapt_last_paydt )
where xapt_comp = @p_comp and xapt_vend = @p_vend and xapt_asof_date = @p_asofdate
GO

View 4 Replies View Related

Ideas For Next Version ...

Jan 12, 2007

To Whom It Concerns - MS Product Design - SQL Server Reporting Services:

I've been working with an ASP.NET web based project utilizing SQL Server Reporting Services for a while and have some things that I think need to be addressed in the next version:

1) I finally got security working utilizing the form based authentication of my Web based app and passing that to SSRS through the ReportViewer control. Not that it was easy. From what I see, a lot of people are having problems with this and so I didn't feel like I was alone. That said, instructions on how to do it need to be easier. Ultimately, it would be better if on the ReportViewer control, you could add properties as follows:


* Impersonate SSRS User

* Impersonization Password
2) Maybe I'm missing something, but in the web app the system logs in to different production databases based on the user id. The only way that I can figure out how to make the same reports available to each database (all on the same SQL Server DB) is to copy the reports and change the data source in the copied directory to copy to the new DB in SQL Server. Could ReportViewer contain a property that allows you to override the connection sring?
3) You have the ability to create PDF's. This is a very nice feature. However, I would like to extend the capabilities that you have. I want to be able to embed a PDF inside the report and have it generated in-line with the report. As an example, I have meta data concerning the PDF kept in the database. When the report prints, I want the meta data printed and the full PDF referenced by the meta data to print. I actually posted a message concerning this to find that there is no solution - I've seen that many people have looked at the message indicating that they are interested in the same feature.
4) It would be nice to have additional controls available - panel, calendar , checkbox, checkboxlist, radiobutton, radiobuttonlist and hyperlink in particular.
5) Dashboard widgets that we can use. Your promoting SSRS as a way to build data decision front ends. It would be nice if out of the box SSRS included several widgets that we could use as indicators to metrics being tracked by the system. As it stands, I can do simple bar, line and pie charts and that is about it. No progress bar, no guages. It would be nice to have some sexier graphing components.
All in all, I do like the product. It was a pain to get setup due to the authentication issues, but I do like it.
David L. Collison
Any day above ground is a good day!

View 3 Replies View Related

Ideas Needed For This Sproc

Jan 24, 2008

Hi,
I want to write a sproc whose main table is Order and it inner joins another table called OrderShipTo with a one to many relationship so the way i have written the first query is as follows
 SELECT
o.OrderId,
o.OrderDate,
o.PlanId,
o.CreatedByUserId,
o.Quantity,
o.BillToCompany,
o.BillToContact,
o.BillToAddress,
o.BillToCity,
o.BillToState,
o.BillToZip,
o.BillToEmail,
o.BillToPhone,
o.ShipToIsBillTo,
o.BookTypeId,
o.RequiredDeliveryDate,
o.SpecialInstructions,
o.ApprovedBy,
o.ApprovedByPhone,
o.ApprovedByEmail,
os.ShipToId,
os.ShipTypeId,
os.ShipToCompany,
os.ShipToContact,
os.ShipToAddress,
os.ShipToAddress1,
os.ShipToCity,
os.ShipToState,
os.ShipToZip,
os.ShipToEmail,
os.ShipToPhone,
os.Quantity
FROM
[Order] o
Inner Join OrderShipTo os on o.OrderId = os.OrderId
WHERE
o.OrderId = @OrderId
 So suppose if i give an OrderId of 15 In the OrderShipTo table they may be 3 Or 2 or none entries for this order in the Ordership to Table So if there is 3 entries in the OrderShip i will get 3 rows of data which is correct... But i just want o.Columns to appear once and i want n rows for the os.Columns to appear.
So in Order To acheive i wrote this query DECLARE @OrderId int
SET @OrderId = 311
SELECT
o.OrderId,
o.OrderDate,
o.PlanId,
o.CreatedByUserId,
o.Quantity,
o.BillToCompany,
o.BillToContact,
o.BillToAddress,
o.BillToCity,
o.BillToState,
o.BillToZip,
o.BillToEmail,
o.BillToPhone,
o.ShipToIsBillTo,
o.BookTypeId,
o.RequiredDeliveryDate,
o.SpecialInstructions,
o.ApprovedBy,
o.ApprovedByPhone,
o.ApprovedByEmail
FROM
[Order] o
WHERE
o.OrderId = @OrderId
EXEC usp_OrderShipToLoadByOrderId @OrderId

 
 
But at the end i want all the rows o.Columns + the rows from os.columns... I also tried giving a union of both the tables but that didnt work of type mismatch..
How can i acheive that???
 Regards
Karen

View 5 Replies View Related

Performance Degradation - Any Ideas?

Apr 11, 2001

Hi all,

Up until recently one of our SQL 7 databases has been running quite happily. However over the last 2 weeks the users have started to complain about performance levles, operations that would normally take 2-3 seconds now run for about 40 seconds. I have rebuilt all indexes and even ran update statistics althought both the 'Auto create Statistics' and 'Auto update statistics' are turned on. This failed to help so I ended up stopping and starting SQL server but still no luck.

I have run a DBCC SHOWCONTIG and the fragmentation is well within acceptable levels, scan desnity is at 94%. The only other thing I can think of is to reboot the NT server as it has been up for 67 days now. Can anyone else think of anything I might have overlooked?

All replies welcome.

Thanks.

View 2 Replies View Related

Challenging Scenerio - All Are Welcome For Ideas

Feb 7, 2000

I have about 20 remote databases that I need a query/scheduled task to run that generates a .rpt file. That part I can get.

However, I need to get this file to another company (via email or ftp, etc) and make it automated.

For example:

Scheduled task runs twice a month and generates a file that then needs to be emailed to an individual or ftp'd to a ftpsite. Is there a way to do this in SQL 7.0 (or 6.5)?

Thanks for all your help,
Laura

View 2 Replies View Related

How To Best Approach The Problem - Need Ideas

Mar 18, 2008

SELECT DISTINCT WO_NO, wo_type, wo_status (incomp,compl,open), wo_status_code, wo_create_date, wo_post_date

I need to do a stored proc in sql server 2005 where I have to count the total work orders based on their wo_type + wo_status, i.e. open, compltd, incomplete. For example I may have (wo_types) AB, AC, AD, orders that are in open status. I need to count the total AB_Type, AC_Type, AD_Type then the total of all 3 in another column (as Total Open). I must do this for all wo_status.

I also have to allow the user to be able to enter the date they want. I.e. if they would want to know on 3/17/08 how many orders were opened that day only. I know I have to use a parameter for this but how do i do that?

Should I do separate select statments for each status, multiple tables ?

Also for 'open' wo_status the wo_status_code can change from O to S but it is still considered 'open'. For this wo_status how can I get the most recent status_code for the open order, i.e., I want to count a particular 'open'work order's - most recent status_code in the work order count for a given wo_type -->> the order should only be counted once on any given date entered. So if the status changed from O then S the same at 1pm then 2pm, respectively, then only the 2pm status should be counted. Thanks in advance for your assistance.

View 2 Replies View Related

LDIFDE Csv Import To SQL - Looking For Ideas

Dec 25, 2005

This is a tuffie, but I think I'll learn new techniques in SQL.I wish to put data from MS Active Directory and put it into a table.Specificly I want user information (first name, last name and so forth)and the groups that they belong into a SQL table.LDIFDE is a utility that can create a csv file from an AD server. Thisis a sample output:dn: CN=rob camarda,OU=Corporate,OU=GeographicLocations,DC=strayer,DC=educhangetype: addobjectClass: topobjectClass: personobjectClass: organizationalPersonobjectClass: usercn: rob camardagivenName: robmemberOf: CN=Arlington Admin,OU=Campus Domain Admin,DC=strayer,DC=edumemberOf:CN=Arlington,OU=Arlington,OU=Region2,OU=Geographic Locations,DC=strayer,DC=edumemberOf: CN=RN Report Consumers,OU=Cognos ReportNet,DC=strayer,DC=edusAMAccountName: rob.camardadn: CN=Robert A. Camarda,OU=TechnologyGroup,DC=strayer,DC=educhangetype: addobjectClass: topobjectClass: personobjectClass: organizationalPersonobjectClass: usercn: Robert A. CamardagivenName: RobertmemberOf: CN=Role Regional Director,OU=Roles,DC=strayer,DC=edumemberOf: CN=Role Campus Director,OU=Roles,DC=strayer,DC=edumemberOf: CN=TLSAdmin,OU=Talisma-Users,DC=strayer,DC=edumemberOf: CN=ASPTestReports,OU=Roles,DC=strayer,DC=edumemberOf: CN=IT Report Authors,OU=Roles,DC=strayer,DC=edumemberOf: CN=Developers,OU=TechnologyGroup,DC=strayer,DC=edu memberOf: CN=SQL Backup Admin,OU=TechnologyGroup,DC=strayer,DC=edumemberOf: CN=RN Report MetaData Modelers,OU=CognosReportNet,DC=strayer,DC=edumemberOf:CN=RN Corporate,OU=Corporate,OU=Region2,OU=GeographicLocations,DC=strayer,DC=edumemberOf:CN=Arlington,OU=Arlington,OU=Region2,OU=Geographic Locations,DC=strayer,DC=edumemberOf: CN=RN Administrator System,OU=CognosReportNet,DC=strayer,DC=edumemberOf: CN=RN Administrator Server,OU=CognosReportNet,DC=strayer,DC=edumemberOf: CN=RN Report Authors,OU=Cognos ReportNet,DC=strayer,DC=edumemberOf: CN=Backup Operators,CN=Builtin,DC=strayer,DC=edumemberOf: CN=Domain Admins,CN=Users,DC=strayer,DC=edumemberOf: CN=Administrators,CN=Builtin,DC=strayer,DC=edusAMAccountName: robert.camardaIn this output, each user is separated by a blank line. sAMAccountNameis the user's login ID to ADS. Lines starting with memberOf: shows thepath for each group the user belongs.My thought is to load the text data into a SQL table with the PK beingthe line number. This way the data will stay together. The secondcolumn would be just text, varchar(100).I'd like to end up with a table something likeUSER_ID, GROUP_MEMBERSHIP, GIVENNAMEIn the example of robert.camarda, that user belongs to 7 groups, sothere would be 7 records, one for each group. I think once I have thispart, I can build my final table with PK's an all the good-housekeeping of a SQL Table.Now the part that I have no idea how to solve:How do I convert the data from unfriendly for databases, to something Ican use?1. I know I have a new user when I find dn:2. I know I am done with the user when I get a blank (null) line.3. I know what I want to populate rows with name and the contents onceI find rows starting with memberOf:4. It appears there is a max line length that LDIFDE will export, andstarts a new line. So, it will be necessary to join lines.I would think this is a combo of CURSORS, a do/while loop and otherassorted magic.If someone can help me get started, I would have something to reseachor model from. As of now, im staring and a blank page and not sure howto start. Maybe someone knows of a simular problem that can share theSQL.TIARob

View 1 Replies View Related

Need Help/ideas On Writing A Function (UDF)

May 1, 2008


I would like to write a user defined function that takes as an input a varchar and returns an xml. If the string is valid xml the function would just return it. If the string is not valid xml then the function would encode the value before returning it.

The function would look something like this:





Code Snippet

CREATE FUNCTION dbo.EncodeXMLIfNotValid (

@InputString varchar(max)

)

RETURNS xml

AS

BEGIN

DECLARE @xml xml

BEGIN TRY

SET @xml = CAST(@InputString as xml)

END TRY

BEGIN CATCH

SET @xml = '<![CDATA[' + @InputString + '>]]>'

END CATCH

RETURN( @xml )

END




However, after writting this I figured out that using BEGIN TRY and CATCH is not allowed in a UDF.

Any thoughts or ideas how I could write a function with this behavior?

Bob

View 6 Replies View Related

Any Ideas To Implement This In SSIS?

Feb 26, 2008



Hi,

I need some help regarding SSIS.

I have a table containing a list of source table names to be transferred to destination.I need to pass each and every table name as a variable and based on the name of the variable I need to select data from source and insert into destination.The source and destinations are on 2 different servers.The source tables have different metadata (different column names and data types).Any help how to implement this would be greatly appreciated.


To be more clear I have List table which has below format

TABLE NAME
CUSTOMER
PRODUCT
INVENTORY

Customer , product, inventory are tables names. So my package should first go and collect the table name from LIST table and then transfer the Customer table data from Server A to Server B. This should be repeat untill all the tables listed in LIST table are transferred.

View 3 Replies View Related







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