Possibly Extremely Simple SQL Query

Jan 27, 2004

Right, I'm no SQL programmer. As I type this, I have roughly the third the hair I had at 5 o'clock last night. I even lost sleep over it.





I'm trying to return a list of records from a database holding organisation names. As I've built a table to hold record versions, the key fields (with sample data) from a View I created to display this is as follows:





record_id-----org_id-----live-----version


====== ===== === =====


1-------------1----------0----------1


2-------------2----------0----------1


3-------------1----------1----------2


4-------------2----------0----------2





as you can see the record id will always be unique. record 3 is a newer version of record 1, and 4 of 2. the issue is thus: i only want to return unique organisations. if a version of the organisation record is live on the system (in this case record id 3), i want to return the live version with its unique record id. i'm assuming for this i can perform a simple "SELECT WHERE live = 1" query.





however, some organisations will have no live versions (see org with id 2). i still wish to return a record for this organisation, but in this case the most recent version ie version 2 (and again - its unique record id)





in actual fact, it seems so much clearer when laid out like this. however, i feel it's not going to happen this end, and so any help would be greatly appreciated.





many thanks in advance,





phil

View 2 Replies


ADVERTISEMENT

Possibly Simple Query But I'm Not Good Enough To Fathom It!

Mar 8, 2006

Hi AllI know that I should supply the DDL for the tables I'm going to talk about,but I'm not 100% on how to generate them just yet. Hopefully my question ismore a query methodology question than how the tables are constructed.My first attempt at the query is as follows:SELECT st.STOCKID, sd.FULLDESCRIPTION, sc.NAME, Sum(sq.QUANTITYINSTOCK) AS'Qty In Stock Total', Sum(st.QUANTITY) AS 'Qty Sold'FROM STOCK s, STOCKCATEGORIES sc, STOCKDESCRIPTIONS sd, STOCKQUANTITIES sq,STOCKTRANSACTIONS stWHERE sc.STOCKCATEGORYID = s.STOCKCATEGORYID AND st.STOCKID = s.STOCKID ANDsd.STOCKID = s.STOCKIDAND sq.STOCKID = s.STOCKID AND (sd.LANGUAGEID='UK') AND(st.TRANSACTIONTYPE=8) AND(sq.QUANTITYINSTOCK > 0)GROUP BY st.STOCKID, sd.FULLDESCRIPTION, sc.NAMEThis works in a fashion, but I need to sort of query the stocktransactionstable again to get the sum of the st.QUANTITY table for st.TRANSACTIONTYPE=1so that I can have an extra select field of Sum(st.QUANTITY) AS 'QtyOrdered', ie transactions with transactiontype of 1 are sales orders andtype 8 are invoices.I basically need to get a report result of:PRODUCT, DESCRIPTION, CATEGORY, CURRENT_STOCK_QTY, SALES_IN_PERIOD,ORDERS_IN_PERIODIs there any pointers whatsoever you can give me to try and get thisdouble-double query to work?Many thanks.Rgds Laphan

View 3 Replies View Related

Query Help - Select Distinct Possibly?

Oct 26, 2006

I need to return the current case cost for every UPC in my table. In my current query I return case costs that have an effective date of today or earlier. The problem is that in my results, one UPC may have two or more case costs that were are effective <= GETDATE(). I can sort it by effective date (DESC) so I know the first of every UPC in my results will be the current effective case cost, but how do I modify my query so that in my result set I only get the first of every UPC?

Here is my query:

SELECT factCaseCosts.nUpcKey, factCaseCosts.dCaseCost, factCaseCosts.dtEffectiveDate
FROM factCaseCosts
WHERE (factCaseCosts.dtEffectiveDate <= GETDATE())
ORDER BY dtEffectiveDate DESC

Here is my current result set:
52023.762006-08-01 00:00:00
52023.762006-02-18 00:00:00
52123.762006-08-01 00:00:00
52123.762006-02-18 00:00:00
52230.362006-08-01 00:00:00
52230.362006-02-18 00:00:00
52323.762006-08-01 00:00:00
52323.762006-02-18 00:00:00

I only want the first 520 returned, the first 521 returned, the first 522 returned, and the first 523 returned.
How can I do this?
Thanks!

View 3 Replies View Related

Possibly Incorrect Query Result

Jul 13, 2006

/* Test table */
create table test (c1 char(1), c2 varchar(1));
insert into test values ('','');

/* Query */
select
c1,
len(c1) len_c1,
c2,
len(c2) len_c2
from test


The result of the len(c1) expression is 0. I would expect the correct result to be 1, since "c1" is a fixed-length character string type and the values are right-padded with spaces to fit the defined length, in this case 1.

I'm using SQL Server 2005.

Regards,
Ole Willy Tuv

View 1 Replies View Related

EXtremely Long Time In Execution Query

Mar 21, 2007

Hi all,

I have a query, rather complex one to deal with more than 1 million rows, used to run 40 minutes in SQL Server 2000 in query analyzer. Now, it has been 10 hours in SQL Server 2005 in management studio. And still has not finished yet! Anything can go wrong here. Basically nothing changes, except for I have my server upgrade from SQL Server 2000 to SQL Server 2005. Seems something is wrong crazy in SQL Server 2005. Any suggestions?

Thanks,

Ning

View 3 Replies View Related

Extremely Poor Query Performance - Identical DBs Different Performance

Jun 23, 2006

Hello Everyone,I have a very complex performance issue with our production database.Here's the scenario. We have a production webserver server and adevelopment web server. Both are running SQL Server 2000.I encounted various performance issues with the production server with aparticular query. It would take approximately 22 seconds to return 100rows, thats about 0.22 seconds per row. Note: I ran the query in singleuser mode. So I tested the query on the Development server by taking abackup (.dmp) of the database and moving it onto the dev server. I ranthe same query and found that it ran in less than a second.I took a look at the query execution plan and I found that they we'rethe exact same in both cases.Then I took a look at the various index's, and again I found nodifferences in the table indices.If both databases are identical, I'm assumeing that the issue is relatedto some external hardware issue like: disk space, memory etc. Or couldit be OS software related issues, like service packs, SQL Serverconfiguations etc.Here's what I've done to rule out some obvious hardware issues on theprod server:1. Moved all extraneous files to a secondary harddrive to free up spaceon the primary harddrive. There is 55gb's of free space on the disk.2. Applied SQL Server SP4 service packs3. Defragmented the primary harddrive4. Applied all Windows Server 2003 updatesHere is the prod servers system specs:2x Intel Xeon 2.67GHZTotal Physical Memory 2GB, Available Physical Memory 815MBWindows Server 2003 SE /w SP1Here is the dev serers system specs:2x Intel Xeon 2.80GHz2GB DDR2-SDRAMWindows Server 2003 SE /w SP1I'm not sure what else to do, the query performance is an order ofmagnitude difference and I can't explain it. To me its is a hardware oroperating system related issue.Any Ideas would help me greatly!Thanks,Brian T*** Sent via Developersdex http://www.developersdex.com ***

View 2 Replies View Related

Possibly A BUG In 6.5

Dec 8, 1999

I have a situation where I may have found a bug in SQL 6.5. I have a process that creates a temp table, then calls a stored procedure that uses that temp table, and the temp table has an identity column on it. The second procedure declares a cursor using an ORDER BY clause on the identity column and spins through the records, updating each row. The below sample is a test case that I think proves the bug. If you remove the ORDER BY clause from the cursor declaration, it works fine. Because of the nature of our data, we have to have the ORDER BY clause.

If you put the following code in a window, run it, you'll see. Then remove the ORDER BY and rerun and you'll get good results. Has anyone seen this or know of a work around? The only solution I have for a workaround is to select the data from the temp table into another temp table and declare the cursor on the second temp table. That seems to work fine. Any suggestions will be appreciated.

SQL SERVER 6.5 - SP5a; NT 4.0 SP5

Thanks,
Mike Nolen
Dealer Solutions Sr. DBA
Houston, TX



-----------SNIP AND RUN------------
-- just needed for the below proc to compile...
create table #mn_temp (
col1 int identity NOT NULL,
col2 char(1)NOT NULL
)
go

drop proc mn2
go
create proc mn2
as
begin
declare @iint, @cchar(1)

-- insert a few records
insert into #mn_temp values ('A')
insert into #mn_temp values ('B')
insert into #mn_temp values ('C')
insert into #mn_temp values ('D')
insert into #mn_temp values ('E')

-- cursor should spin through 5 records
declare aaa cursor for
select col1, col2 from #mn_temp
order by col1

open aaa

fetch next from aaa into @i, @c
select @@fetch_status "fs", @i "ident", @c "char"

while (@@fetch_status <> -1)
begin
print 'In while loop'

fetch next from aaa into @i, @c

-- should print 1A, 2B, 3C, 4D, 5E...but it doesn't!!!
select @@fetch_status "fs", @i "ident", @c "char"
end
close aaa
deallocate aaa
end
go

-- temp table no longer needed...drop it before compiling mn0...
drop table #mn_temp
go

drop proc mn0
go
create proc mn0
as
begin
create table #mn_temp (
col1 int identity NOT NULL,
col2 char(1) NOT NULL )

exec mn2
end
go

View 4 Replies View Related

Possibly Merge Join Bug?

Mar 27, 2006

i'm merge joining 2 data sources, one is oracle and the other is excel...the problem is in the oracle source, it's a sql statement like:

select hdr.div_ord_no, hdr.mtr_no, hdr.prod_cd
from qctrl_div_ord_header hdr,
(select max(sub.eff_dt_from) min_eff_dt_from, div_ord_no
from qctrl_div_ord_header sub
group by div_ord_no
) tmp
where hdr.eff_dt_from = tmp.min_eff_dt_from
and hdr.div_ord_no = tmp.div_ord_no

having that sql statement, merging will come out with 0 rows

however, having a simple query like:

select hdr.div_ord_no, hdr.mtr_no, hdr.prod_cd
from qctrl_div_ord_header hdr

merging will come out with 2 rows

you may think that the data in the first sql statement is not there for the merge, which causing the 0 rows, however, the data is there, i'm only joining by one column and definitely the data is there, the merge result should be 2 rows for both query statements

i believe this is a problem with SSIS, anyway around this?

View 2 Replies View Related

Autogrow Of Log File Possibly Cause Timeout?

Jan 30, 2007

i had a problem with a server instance where an app processing a file and putting the data into the database using a stored procedure was timing out. the app is a service and in the case of errors, will try to process the file until it has been succesfully added data to the database. in the event viewer i keep seeing this message during this timeout period:

"Autogrow of file 'mydatabase_log' in database 'mydatabase' was cancelled by user or timed out after 15687 milliseconds. Use ALTER DATABASE to set a smaller FILEGROWTH value for this file or to explicitly set a new file size."

is there a possibility that this process was causing my SP to timeout? are there any other log or debug files that SQL Express creates that might be helpful in discovering what caused the timeout? currently the log is at... ouch 10gigs restricted... maybe trying to autogrow from this while restricted is hogging resources?

View 9 Replies View Related

Question About Database Mirroring And Possibly NLB

Sep 12, 2006

OK since my company really would not prefer to spend the money for Windows 2003 Enterprise and MS SQL 2005 Enterprise I was thinking about this idea...

Server1 - W2K3 Std - SQL2005 Std - Primary
Server2 - W2K3 Std - SQL2005 Std - Mirror
Server3 - W2K3 Std - SQL2005 Std - Witness
Server4 - W2K3 Std - SQL2005 Std - Processing

OK So we have Server1 & Server2 doing the Database Mirroring. Then I have Server3 as the Witness to say who is the Primary and so forth. Now Server4 I thinking to us to create jobs that will run on a Schedule to pull data from our Ticketing system and import it into Server1 & Server2 (Yes this is a Datawarehouse).. So what I am wondering... We really wish to not have to change our connections to the DB with the Failover connection string and just use a common name. Since we are not usng Enterprise I can not do the Failover Clustering... So what I was wondering is if we could use the MS NLB. So for example with Server1 being primary and Server2 being Mirror... Server1 dies or goes down for maintance or whatever... Then Server3 will notice that and say OK Server2 you are now primary but also have Server3 go into the MS NLB and say Server3 Online and take all connections. Then when Server1 comes back on-line it is set as the Mirror system and is Offline in the NLB... Is this possible? If yes can someone either A... Give me directions on how to do that... or B shot me some URL's where I can read up on this stuff?

Thanks for all your help anyone is able to provide. It is greatly appricated.

Billy S.

View 14 Replies View Related

SUM And JOIN And Possibly GROUP BY - Incorrect Value Returned By SUM

Mar 23, 2006

It's me again :)

So; if you read my earlier thread here (http://www.dbforums.com/showthread.php?t=1214353), you'll know that I'm trying to build stored procedures to deal with ticketing queries, and that it's all getting a bit complicated. I have, however, made a bit of progress and now have the following working:


CREATE PROCEDURE [dbo].[getAvailableTickets]
@eventId INT,
@standId INT,
@admissionDateId INT,
@concessionId INT,
@userId INT

AS

DECLARE @startyear DATETIME
DECLARE @endyear DATETIME
SELECT @startyear=CONVERT(datetime, '2006/01/01')
SELECT @endyear=CONVERT(datetime, '2006/12/31')


SELECT
[tblTickets].[id] AS ticketId,
[tblEvents].[id] AS eventId,
[tblStands].[id] AS standId,
[tblAdmissionDates].[id] AS admitDateId,
[tblEvents].[event_name],
[tblStands].[stand_name],
[tblTicketConcessions].[concession_name],
[tblMemberships].[membership_name],
[tblAdmissionDates].[admission_start_date],
[tblAdmissionDates].[admission_end_date],
[tblBookingMinQuantities]. AS minBookingQuantity,
[tblBookingMaxQuantities].[booking_quantity] AS maxBookingQuantity,
MIN([tblQuotas].[quota]) AS Quota,
[B]SUM([tblBasket].[ticket_quantity]) AS History,
[tblTickets].[price],
[tblTickets].[availability]

FROM [tblTickets]
LEFT JOIN [tblEvents]ON [tblEvents].[id] = [tblTickets].[event_id]
LEFT JOIN [tblStands]ON [tblStands].[id] = [tblTickets].[stand_id]
LEFT JOIN [tblBookingDates]ON [tblBookingDates].[id] = [tblTickets].
LEFT JOIN [tblTicketConcessions]ON [tblTicketConcessions].[id] = [tblTickets].[ticket_concession_id]
LEFT JOIN [tblBookingQuantities] AS tblBookingMinQuantities ON [tblBookingMinQuantities].[id] = [tblTickets].[booking_min_quantity_id]
LEFT JOIN [tblBookingQuantities] AS tblBookingMaxQuantitiesON [tblBookingMaxQuantities].[id] = [tblTickets].[booking_max_quantity_id]
LEFT JOIN [tblAdmissionDates]ON [tblAdmissionDates].[id] = [tblTickets].[admission_date_id]
LEFT JOIN [tblMemberships]ON [tblMemberships].[id] = [tblTickets].[membership_id]
LEFT JOIN [tblQuotas]ON
([tblQuotas].[event_id] = [tblTickets].[event_id] OR [tblQuotas].[event_id] IS NULL) AND
([tblQuotas].[stand_id] = [tblTickets].[stand_id] OR [tblQuotas].[stand_id] IS NULL) AND
([tblQuotas].[admission_date_id] = [tblTickets].[admission_date_id] OR [tblQuotas].[admission_date_id] IS NULL) AND
([tblQuotas].[concession_id] = [tblTickets].[ticket_concession_id] OR [tblQuotas].[concession_id] IS NULL) AND
([tblQuotas].[membership_id] = [tblTickets].[membership_id] OR [tblQuotas].[membership_id] IS NULL) AND
([tblQuotas].[ticket_id] = [tblTickets].[id] OR [tblQuotas].[ticket_id] IS NULL)
[B]LEFT JOIN [tblBasket] ON [tblBasket].[ticket_id] = [tblTickets].[id]
LEFT JOIN [tblOrders] ON [tblOrders].[id] = [tblBasket].[order_id]

WHERE 1=1
AND ([tblTickets].[ticket_open] = 1)
AND (([tblEvents].[id] = @eventId OR @eventId = 0)AND ([tblEvents].[event_open] = 1))
AND (([tblStands].[id] = @standId OR @standId = 0)AND ([tblStands].[stand_open] = 1))
AND (([tblAdmissionDates].[id] = @admissionDateId OR @admissionDateId = 0)AND ([tblAdmissionDates].[date_open] = 1))
AND ([tblTicketConcessions].[id] = @concessionId OR @concessionId = 0)
AND ((getdate() BETWEEN [tblBookingDates]. AND [tblBookingDates].[booking_end_date]) OR ([tblBookingDates].[booking_start_date] IS NULL AND [tblBookingDates].[booking_end_date] IS NULL))
AND (([tblMemberships].[id] IN (SELECT [membership_id] FROM [tblUsers_Memberships] WHERE [user_id]=@userId)) OR [tblMemberships].[id] IS NULL)
[B]AND ([tblOrders].[user_id] = @userId OR @userId=0)

GROUP BY
[tblTickets].[id],
[tblEvents].[id],
[tblStands].[id],
[tblAdmissionDates].[id],
[tblEvents].[event_name],
[tblStands].[stand_name],
[tblTicketConcessions].[concession_name],
[tblMemberships].[membership_name],
[tblAdmissionDates].[admission_start_date],
[tblAdmissionDates].[admission_end_date],
[tblBookingMinQuantities].[booking_quantity],
[tblBookingMaxQuantities].[booking_quantity],
[tblTickets].[price],
[tblTickets].[availability]
GO



Except... there's two problems with it. One is that it only returns tickets that you've already bought, the other is that it doens't work out correctly how many of those tickets you've bought in past orders.

This is what's in tblBasket:


idticket_idquantityorder_iddate
152321/03/2006
262321/03/2006
3144421/03/2006
4154421/03/2006
551421/03/2006


Both the orders in there are for the same user id: "1". All the tickets in there are tied to event "2".

When I run Exec dbo.getAvailableTickets 2,0,0,0,1, it tells me it's found 6 of ticket 5, 4 of ticket 6 and 12 of ticket 14. And I can't for the life of me figure out how it's calculating it. Any ideas?

And how do i get it to return all tickets regardless of whether you've bought them previously or not?

View 4 Replies View Related

Need To Go Down Path To Find If Everything Is Settled (recursive Possibly)

May 1, 2007

I have the following table.GO/****** Object: Table [dbo].[itTransactionProcess] Script Date:05/01/2007 10:42:31 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCREATE TABLE [dbo].[itTransactionProcess]([TransactionID] [int] IDENTITY(1,1) NOT NULL,[LotNumber] [int] NOT NULL,[CurrentProcessStepID] [int] NOT NULL,[NextProcessStepID] [int] NULL,[CategoryID] [int] NULL,[ProductID] [int] NULL,[ProductVariantID] [int] NULL,[ParentTransactionID] [int] NULL,[TransactionDateEntered] [datetime] NULL,[TransactionDateExit] [datetime] NULL,[Settlement] [money] NULL,[Completed] [int] NULL,CONSTRAINT [PK_itTransactionProcess] PRIMARY KEY CLUSTERED([TransactionID] ASC)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY= OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]Sample data is as followsBasically what I need to do is return the lotid where all path have asettlement date.this is my current procedure/****** Object: StoredProcedure [dbo].[getPendingSettlementDetails] Script Date: 05/01/2007 10:47:47******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[getPendingSettlementDetails]ASdeclare @LotNumbersTable table(LotNumber int)insert into @LotNumbersTable EXEC GetPendingSettlementsLotNumbersDeclare @ResultsTable table(LotNumber int, Company varchar(150),Contact varchar(150), DateReceived datetime, DateComplete datetime,SettlementLength int)Declare @LotNumber intDeclare @DateRecieved datetime, @DateComplete datetimeDeclare @NumberOfDaysForSettlement intDeclare @Company varchar(150)Declare @Contact varchar(150)select @LotNumber = min(LotNumber) from @LotNumbersTablewhile @LotNumber is not null beginSelect @DateRecieved = min(TransactionDateEntered) fromitTransactionProcess where LotNumber = @LotNumberSelect @DateComplete = max(TransactionDateExit) fromitTransactionProcess where LotNumber = @LotNumber and Settlement isnot nullSET @NumberOfDaysForSettlement = DATEDIFF(DAY, @DateRecieved,@DateComplete)Select @Company = Company from SP_Active_Lot_Deliveries where LotID =@LotNumberSelect @Contact = ContactName from SP_Active_Lot_Deliveries whereLotID = @LotNumberINSERT INTO @ResultsTable (LotNumber, DateReceived, DateComplete,SettlementLength, Company, Contact) Values(@LotNumber, @DateRecieved, @DateComplete,@NumberOfDaysForSettlement, @company, @contact)select @LotNumber = min(LotNumber) from @LotNumbersTable whereLotNumber @LotNumberendSelect * From @ResultsTable where SettlementLength is not nullhere is sample data"TransactionID","LotNumber","CurrentProcessStepID","NextProcessStepID","CategoryID","ProductID","ProductVariantID","ParentTransactionID","TransactionDateEntered","TransactionDateExit","Settlement","Completed""628","47","1","2","5","","","","","2007-05-0110:23:15.747000000","","""629","47","1","3","17","","","","","2007-05-0110:23:15.747000000","0.25","""630","47","1","4","34","","","","","2007-05-0110:23:15.747000000","-0.15","""631","47","1","3","38","","","","","2007-05-0110:23:15.747000000","-0.15","""632","47","1","4","33","","","","","2007-05-0110:23:15.747000000","-0.35","""633","47","1","3","15","","","","","2007-05-0110:23:15.747000000","10","""634","47","2","3","86","","","628","2007-05-0110:23:15.747000000","2007-05-01 10:32:41.320000000","-0.35","""635","47","3","","17","","","629","2007-05-0110:23:15.747000000","","","""636","47","4","","34","","","630","2007-05-0110:23:15.747000000","","","""637","47","3","","38","","","631","2007-05-0110:23:15.747000000","","","""638","47","4","","33","","","632","2007-05-0110:23:15.747000000","","","""639","47","3","","15","","","633","2007-05-0110:23:15.747000000","","","""640","47","2","3","85","","","628","2007-05-0110:24:47.983000000","2007-05-01 10:32:41.320000000","0.05","""641","47","2","4","88","","","628","2007-05-0110:24:56.343000000","2007-05-01 10:32:41.333000000","0.8","""642","47","2","4","9","","","628","2007-05-0110:25:07.517000000","2007-05-01 10:32:41.333000000","-0.15","""643","47","2","4","100","","","628","2007-05-0110:25:22.470000000","2007-05-01 10:32:41.333000000","-0.35","""644","47","2","4","90","","","628","2007-05-0110:25:44.297000000","2007-05-01 10:32:41.333000000","-0.35","""645","47","2","4","12","","","628","2007-05-0110:25:59.347000000","2007-05-01 10:32:41.333000000","-0.15","""646","47","2","4","26","","","628","2007-05-0110:26:12.610000000","2007-05-01 10:32:41.333000000","-0.35","""647","47","2","3","94","","","628","2007-05-0110:26:29.523000000","2007-05-01 10:32:41.333000000","-3","""648","47","2","3","95","","","628","2007-05-0110:26:47.323000000","2007-05-01 10:32:41.333000000","-0.35","""649","47","2","3","38","","","628","2007-05-0110:27:01.450000000","2007-05-01 10:32:41.333000000","-0.15","""650","47","2","4","33","","","628","2007-05-0110:27:15.533000000","2007-05-01 10:32:41.333000000","-0.35","""651","47","2","4","34","","","628","2007-05-0110:27:33.767000000","2007-05-01 10:32:41.333000000","-0.15","""652","47","2","3","96","","","628","2007-05-0110:27:46.850000000","2007-05-01 10:32:41.350000000","-0.35","""653","47","2","3","97","","","628","2007-05-0110:28:00.917000000","2007-05-01 10:32:41.350000000","0.05","""654","47","2","4","36","","","628","2007-05-0110:28:10.813000000","2007-05-01 10:32:41.350000000","-15","""655","47","2","4","37","","","628","2007-05-0110:28:25.347000000","2007-05-01 10:32:41.350000000","0.35","""656","47","2","3","98","","","628","2007-05-0110:28:36.917000000","2007-05-01 10:32:41.350000000","-0.35","""694","47","2","10","26","","","628","2007-05-0110:32:17.170000000","2007-05-01 10:32:41.350000000","","""695","47","2","10","35","","","628","2007-05-0110:32:27.883000000","2007-05-01 10:32:41.350000000","45","""696","47","3","","86","","","634","2007-05-0110:32:41.320000000","","","""697","47","3","","85","","","640","2007-05-0110:32:41.333000000","","","""698","47","4","","88","","","641","2007-05-0110:32:41.333000000","","","""699","47","4","","9","","","642","2007-05-0110:32:41.333000000","","","""700","47","4","","100","","","643","2007-05-0110:32:41.333000000","","","""701","47","4","","90","","","644","2007-05-0110:32:41.333000000","","","""702","47","4","","12","","","645","2007-05-0110:32:41.333000000","","","""703","47","4","","26","","","646","2007-05-0110:32:41.333000000","","","""704","47","3","","94","","","647","2007-05-0110:32:41.333000000","","","""705","47","3","","95","","","648","2007-05-0110:32:41.333000000","","","""706","47","3","","38","","","649","2007-05-0110:32:41.333000000","","","""707","47","4","","33","","","650","2007-05-0110:32:41.333000000","","","""708","47","4","","34","","","651","2007-05-0110:32:41.333000000","","","""709","47","3","","96","","","652","2007-05-0110:32:41.350000000","","","""710","47","3","","97","","","653","2007-05-0110:32:41.350000000","","","""711","47","4","","36","","","654","2007-05-0110:32:41.350000000","","","""712","47","4","","37","","","655","2007-05-0110:32:41.350000000","","","""713","47","3","","98","","","656","2007-05-0110:32:41.350000000","","","""714","47","10","","26","","","694","2007-05-0110:32:41.350000000","","","""715","47","10","","35","","","695","2007-05-0110:32:41.350000000","","",""If you follow transaction id 714 up through the parent transaction idsit doesn't not have a settlement cost yet lot 47 shows up as settled.Thanks for you help.

View 6 Replies View Related

Unknown Backup Running (possibly Unauthorized)

May 1, 2008

Hello everyone.

First off, I know little to nothing about SQL. I run the IIS web server and the programmers run the SQL server. Recently the programmers found a backup running everynight at midnight and its messing up the Differential backups. By that I mean, since the full backup runs, the differential isnt backing anything up since it is set to only backup from the last full backup.

The backup seems to be backing up to a "Virtual Device" and I have no idea what that is. I am unable to see any user associated with the backup and I'm at a total loss as to where the data is going. Can someone please help me resolve this issue. I searched but was unable to find anything as I have no idea what to search for to find where this backup is coming from.


Here is a log from said backup...

Database backed up. Database: dbname, creation date(time): 2008/03/10(03:40:58), pages dumped: 1, first LSN: 288:523:56, last LSN: 288:547:1, number of dump devices: 1, device information: (FILE=1, TYPE=VIRTUAL_DEVICE: {'{B9A0EFAB-8894-4BBC-BC77-82DA1B58E2D4}28'}). This is an informational message only. No user action is required.

Lastly... The programmers do have backups running.. full once a week and differentials inbetween. the problem is, those logs look like this...

Log was backed up. Database: dbname, creation date(time): 2008/04/09(03:32:53), first LSN: 135:305:1, last LSN: 135:305:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'D:ackup imeanddate.BAK'}). This is an informational message only. No user action is required.


Thank you in advance!

View 10 Replies View Related

Is It Possibly To Rollback A Whole Package If One Dataflow Fails?

Apr 22, 2006

I have 4 data flows in a for loop, is it possibly to roll the whole for loop back if any of the transactions fail. Also is it possibly to roll back a dataflow if any of the components inside the dataflow fail?



Cheers

View 1 Replies View Related

Problem With Backups Possibly Caused By Microsoft SQL

Feb 1, 2008



Hello

Am having a problem which started after I installed a databse with sqlexpress. I get this error when backing up "MSDEWriter" has reported an error 0x800423f4

I am running Windows 2003 SBS SP2.

I've checked to make sure that all of my databases are using simple in recovery mode.

Please help

Thanks

View 1 Replies View Related

MS HotFixes/patches Possibly Stunting DB Activity For Certain Amounts Of Data?

Jun 14, 2004

I’m wondering if anyone can shed light on a problem I’ve noticed that's really made for a major thorn in my side. I recently had a Microsoft patch installed on my server, and now for some reason, trying to run INSERT or UPDATE queries against the SQL 2000 database are severely limited. I constantly get the error:

“Error: A severe error occurred on the current command. The results, if any, should be discarded.�

My Event Logs also return the following:

"Invalid buffer received from client."

I think I’ve isolated the problem to be that I can’t add new or modify existing records that try using a field which is of type TEXT, but now can’t be longer than 4,000 characters, else the error fires. This is really weird, as I’ve used the same ASP.NET script to call a stored procedure to INSERT/UPDATE records thousands of times before with 100% success.

I have a feeling this might have something to do with the patch, but has anyone come across this problem specifically, or know for sure which patch(es) cause it? Why all of a sudden would a TEXT field be so limited in capacity?

View 2 Replies View Related

Extremely New

Jan 26, 2007

Hi,

I am very new to SQL, and am basically self-taught(apart from SQL for Dummies and a couple of other books). I am hoping someone can help me with the 'CONVERT' statement.

My system outputs the date format as '12345'. What I have written so far is this;

select Resprj.Re_code, Res.re_desc, resprj.Pr_code, projects.Pr_desc,Res.Re_status1,
Projects.active, Projects.Pr_start, Projects.Pr_end
from res inner join Resprj on (Res.Re_code = resprj.Re_code)
inner join projects on (projects.PR_code = resprj.Pr_code)
and Projects.Pr_desc like '%C9%'
where projects.active =-1
order by Projects.Pr_code, Res.Re_desc

Could someone please help in regards to using the 'CONVERT' statement to change the date from '12345' to dd/mm/yy.

Thanks

Rob

View 6 Replies View Related

Extremely Large Log File

Mar 25, 2008

I have a test db in SQL Server Express 2005 with a 65MB dat file and a 1.1GB log file!!  The production db has a slightly larger dat file and only a 6MB log file.  I haven't updated by test db from the production db in a couple of months.
I tried Shrink Database and Shrink File in the Management Studio Express, but the log file size hasn't changed.
How did the log file get so large and how do I fix it?
Thanks for any help.

View 3 Replies View Related

Transaction Log Extremely Large

Oct 10, 2000

Hello everyone,
I'm not sure if this is a problem but I've got a database which is about 1700mg in size (at least that's the allocated space on disk) and the log file is over 4600 mb. I've truncated the log file but it still keeps growing. None of our other databases are this large and there are a lot of transactions performed regularly but it looks odd to me that the log is this big when the data is half the size. How can I find out exactly how much space is being taken up by the data and is there anything I can do that will shrink the size of the log file? I am not really a dba so I'm not sure how crucial this is in the grand scheme of things.
Thanks

View 1 Replies View Related

Need Help, DTS Is Running Extremely Slow!!!

May 13, 2004

Hi guys.

I have a DTS package ON SQL 2000 which transfer data from AS400 to SQL 2000 using an ODBC Client Access 5.1 (The DSN was configured by a sysdmin on the AS400 so it is configured properly).
When i execute the package manualy (by right click and "execute package") the package runns fine and ruterns data in no time (Eproximatly 30000 rows in 15 sec).

The problem starts when a job executes the same packagee!!!
When i start the job, the DTS package is running Very Very Slow!!!!
sometime it takes Hours to return a few rows! and it seems that it is stuck.

The SQLAgent is running as a NT Account with Administrator rights, and has full access to the AS400!! so the problem is not the Agent.

by monitoring the AS400, i have noticed that the job/DTS is retreaving the first fetch quickly , and then it is in a waiting status

i have tried everything and cant seem to get this problem fixed

Does anyone know what could be the problem?
I Need Help Quick!!!
Thank You

Gil

View 5 Replies View Related

Extremely Slow TSQL

Apr 23, 2008

Hey Guys

I have a huge speed issue on one or two of my SQL Tables. I have included the basic design below.

Structure
Id
ParentId
Name

Group
Id
ParentId
Name
Weight

Products
Id
Name

StructureProducts
StructureId
ProductId
Imported

StructureGroups
StructureId
GroupId

GroupProducts
GroupId
ProductId

AnswerDates
Id
AssessmentDate

Scores <-- This table is the slow table
AnswerDateId
StructureId
GroupId (nullable)
ProductId (nullable)
Score >= 0 && <= 100


Ok, Structures are the start of everything. Structures, have children. If a group/product is Linked to a parent or child structure then that group/product is visible along the structure tree flow path. Groups, like structure have children. And also like structures, if a group is given a product, then that product is visible through the structure tree flow path.

Example:
Earth [Structure]
- Asia [Structure]
--- China [Structure]
--- Japan [Structure]
----- Computer Stuff [Group]
------- Desktops [Group]
------- Servers [Group]
------- Laptops [Group]
--------- HP [Product]
--------- Dell [Product]
--------- Fujitsu [Product]
- Europe [Structure]
--- Germany [Structure]
----- Berlin [Structure]
--- Italy [Structure]
----- Rome [Structure]
----- Venice [Structure]
- America [Structure]
--- United States of America [Structure]
----- New York [Structure]
------- Computer Stuff [Group]
--------- Desktops [Group]
--------- Servers [Group]
--------- Laptops [Group]
----------- HP [Product]
----------- Dell [Product]
------- Home Stuff [Group]
--------- Kitchen Stuff [Group]
--------- bedroom Stuff [Group]
----- Washington [Structure]
------- Computer Stuff [Group]
--------- Desktops [Group]
--------- Servers [Group]
--------- Laptops [Group]
----------- HP [Product]
----------- Dell [Product]
----------- Acer [Product]
------- Home Stuff [Group]
--------- Kitchen Stuff [Group]
--------- bedroom Stuff [Group]
----- Chicago [Structure]
------- Computer Stuff [Group]
--------- Desktops [Group]
--------- Servers [Group]
--------- Laptops [Group]
------- Home Stuff [Group]
--------- Kitchen Stuff [Group]
--------- bedroom Stuff [Group]
- Africa [Structure]
--- South Africa [Structure]
----- Johannesburg [Structure]
------- Computer Stuff [Group]
--------- Desktops [Group]
--------- Servers [Group]
--------- Laptops [Group]
----------- Acer [Product]
------- Home Stuff [Group]
--------- Kitchen Stuff [Group]
--------- bedroom Stuff [Group]
----- Durban [Structure]
----- Capte Town [Structure]
- Australasia [Structure]

So the initial steps that happen (with regards to Scoring) are as follows.
1. Insert root score (which would be for a structure, a group, an answer date and either a product or no product
2. Score the next group up along the treeview, using the scores for the groups at the same level as the original group (0 score if no score exists).
3. Continue this till GroupTree is at root (parentid == null)
4. Using the next structure up along the treeview, repeat steps 2 & 3.
5. Continue steps 4 until Structuree is at root (parentid == null)

Example
Scoring a product for Johannesburg Acer Laptop would go as follows
1. Initial score for [Acer] product against Group [Laptop] for Johannesburg.
2. Calculate Score for all products (productid = null) against Laptop for Johannesburg
3. Calculate Score for [Acer] product against Group [Computer Stuff] for Johannesburg
4. Calculate Score for all products against Group [computer Stuff] for Johannesburg
5. Calculate score for [Acer] product against all root groups for Johannesburg
5.1. Group [Comptuer Stuff] and [Home Stuff]
6. Calculate score for all products against all root groups for Johannesburg
6.1. Group [Comptuer Stuff] and [Home Stuff]
7. Calculate score for [Acer] Product against Group Laptop for South Africa
8. Calculate Score for all products (productid = null) against Laptop for South Africa
9. Calculate Score for [Acer] product against Group [Computer Stuff] for South Africa
10. Calculate Score for all products against Group [computer Stuff] for South Africa
11. Calculate score for [Acer] product against all root groups for South Africa
11.1. Group [Comptuer Stuff] and [Home Stuff]
12. Calculate score for all products against all root groups for South Africa
12.1. Group [Comptuer Stuff] and [Home Stuff]
13. Calculate score for [Acer] Product against Group Laptop for Africa
14. Calculate Score for all products (productid = null) against Laptop for Africa
15. Calculate Score for [Acer] product against Group [Computer Stuff] for Africa
16. Calculate Score for all products against Group [computer Stuff] for Africa
17. Calculate score for [Acer] product against all root groups for Africa
17.1. Group [Comptuer Stuff] and [Home Stuff]
18. Calculate score for all products against all root groups for Africa
18.1. Group [Comptuer Stuff] and [Home Stuff]
etc. etc. etc...

This basicly coveres the concept behind the basic scoring methodology. Now the methodology splits into 2. The first Methodology 1, say it should do these calculations using the Exact same date as the original scored date. (Ie. if i do a score today, only scores on today will be used in the calculations). The other, Methodology 2, says that it should do the calculations on the latest available date. (Ie. If i do a score today, only scores from today and the latest before today will be used in the calculations).

Now to add another problem to this already complex process, is that each Group and each product within a structure can have either of the 2 scoring methodologies assigned to it. Also, products can only be scored against the structures and groups that they are assigned to. Ie, Acer exists in Laptop Group, in Johannesburg or South Africa or Africa, but doesnt exist in New York.

Ok, so now that i've explained briefly how this scoring works, let me get to the heart of the problem. Basicly its speed (can clearly see why), though the speed issue only comes
up in 1 Place. And that is where it has to look backwards for the latest available score for the required group, structure and product.

For this to happen i wrote a function
ALTER FUNCTION [dbo].[GetLatestAnswerDateId]
( @StructureId INT,
@GroupId INT,
@ProductId INT,
@AnswerDateId INT )
RETURNS INT
AS
BEGIN
DECLARE @Id INT
DECLARE @Date DATETIME

SELECT TOP 1 @Date = [Date]
FROM [dbo].[AnswerDate]
WHERE [Id] = ISNULL(@AnswerDateId, [Id])
ORDER BY [Date] DESC

SELECT TOP 1 @Id = ad.id--gs.[AnswerDateId]
FROM [dbo].[Scoring] gs
INNER JOIN [dbo].[AnswerDate] ad ON ad.Id = gs.AnswerDateId
WHERE [StructureId] = @StructureId
AND ISNULL([GroupId], -1) = ISNULL(@GroupId, -1)
AND ISNULL([ProductId], -1) = ISNULL(@ProductId, -1)
AND [Date] <= @Date
ORDER BY [Date] DESC

RETURN @Id
END

Now on small amounts of data (1000 rows or so) its quick, though that is due to the fact that the data is minimal, but on large amounts of data this function runs for along time. Specificly in the context of the following when there is 6 months of scoring data (100 000+ rows) to peruse.

SELECT [StructureId], [GroupId], [AnswerDateId], [ProductId], [Score]
FROM [Scoring]
WHERE AnswerDateId = GetLatestAnswerDateId([Structure], [GroupId], [ProductId], null)
AND [StructureId] = South Africa
AND [GroupId] = Computer Stuff
AND [ProductId] = Acer



Any idea's on how to make this quick? or quicker?

My Current runtime for calculating the 2500 base scores (totals 100 000+- rows) takes 15 hours. Though this is an initial calculation and is only supposed to be done once.
Also, this calculations are all correct, so my only issue itself is the speed of the entire process.

Thanks In Adance

Jonathan

WARNING: Running on cold coffee!

View 7 Replies View Related

Extremely Large Log Files?

Aug 16, 2006

We have SQL Server running on a Windows 2003 server, only because Backup Exec requires it. AT the location : C:Program FilesMicrosoft SQL ServerMSSQLData
there is this file: SuperVISorNet_log.LDF which is 15 Gb and is accessed daily. I apologize because I don't know what this is!

My question is: can this file be 'pruned' (for want of a better word) because it's taking up a lot of backup space.

View 17 Replies View Related

Extremely Slow Table

Sep 16, 2005

Hi,I have a table defined asCREATE TABLE [SH_Data] ([ID] [int] IDENTITY (1, 1) NOT NULL ,[Date] [datetime] NULL ,[Time] [datetime] NULL ,[TroubleshootId] [int] NOT NULL ,[ReasonID] [int] NULL ,[reason_desc] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[maj_reason_id] [int] NULL ,[maj_reason_desc] [nvarchar] (255) COLLATESQL_Latin1_General_CP1_CS_AS NULL ,[ActionID] [int] NULL ,[action_desc] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[WinningCaseTitle] [nvarchar] (255) COLLATESQL_Latin1_General_CP1_CS_AS NULL ,[Duration] [int] NULL ,[dm_version] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[ConnectMethod] [nvarchar] (255) COLLATESQL_Latin1_General_CP1_CS_AS NULL ,[dm_motive] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[HnWhichWlan] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[RouterUsedToConnect] [nvarchar] (255) COLLATESQL_Latin1_General_CP1_CS_AS NULL ,[OS] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL ,[WinXpSp2Installed] [nvarchar] (255) COLLATESQL_Latin1_General_CP1_CS_AS NULL ,[Connection] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[Login] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL,[EnteredBy] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_ASNULL ,[Acct_Num] [int] NULL ,[Site] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL ,CONSTRAINT [PK_SH_Data] PRIMARY KEY CLUSTERED([TroubleshootId]) ON [PRIMARY]) ON [PRIMARY]GOWhich contains 5.6 Million rows and has non clustered indexes on Date,ReasonID, maj_Reason, Connection. Compared to other tables on the sameserver this one is extremely slow. A simple query such as :SELECTSD.reason_desc,SD.Duration,SD.maj_reason_desc,SD.[Connection],SD.aolEnteredByFROM dbo.[Sherlock Data] SDWhere SD.[Date] > Dateadd(Month,-2,Getdate())takes over 2 minutes to run ! I realise the table contains severallarge columns which make the table quite large but unfortunately thiscannot be changed for the moment.How can i assess what is causing the length of Query time ? And whatcould i possibly do to speed this table up ? The database itself isrunning on a dedicated server which has some other databases. None ofwhich have this performance issue.Anyone have any ideas ?

View 5 Replies View Related

Extremely Long Lines

Sep 22, 2006

Hi,

When i open a project in ssis show the message:

"Document contains one or more extremely long lines of text. These lines will cause the editor to respond slowly when you open the file. Do you still want to open the file."

I click Yes and my project open normally. Someone know why this happen? My project is small, have one package with any imports excel files to Sql Server 2005.

Thanks

André Rentes

View 1 Replies View Related

SSRS2005 Is Extremely Slow

Sep 17, 2007



Hello! I have a query that join five tables and returns around 45000 rows that takes no more than a minute to execute, in management studio, on a SQL Server 2005, 2CPU 32 bit(dual core), 4GB and RAID5 disk system. The O/S is Windows 2003 sp2 Standard Edition.

When the same query is executed in SSRS2005, with some drilldown and summary of drilldown levels, it never stops to execute.

Looking at the hardware in the performance monitor reveals nothing strange except that % CPU-time is around 40 percent. Memory resources over 2 GB are available all the time.

Any suggestions is appreciated!

Any problems with SQL Server 2005 source database running on SQL Server 2000 compatibility level?

Thomas Ivarsson

View 1 Replies View Related

[EXTREMELY URGENT] Sp_attach_db Error

Jul 20, 2005

I am attaching a database with 3 data files.When I execute "exe sp_attache_db..." I obtain this error:database 'POINT' cannot be opened because some of the files could not beactivated.I have deleted its LDF file.Usually I detach my db, then I delete transaction log, and reattach 3 datafiles...Now it doesn'work!!!!!!!!!!Someone can help me?Thanks.

View 1 Replies View Related

Extremely Long Lines Of Text

Sep 25, 2006

I have a dtsx package that works fine with one exception. When I open the dtsx package in BI, it gives me the following message:

Document contains one or more extremely long lines of text. These lines will cause the editor to respond slowly when you open the file. Do you still want to open the file?

When I respond yes, the package opens and I can edit or execute with no problem. Still, I want to understand what could cause this message to occur and, more importantly, how I can get rid of the message. When I try to simply execute the package I still get the same error and it seems this will be a problem for trying to run the package from SQL Server agent.

It seems likely to me that this message refers to the dtsx file (in xml format) itself. Does that make any sense?

View 2 Replies View Related

SSIS Becomes EXTREMELY Slow After SP2 Upgrade

Feb 22, 2007

On a dual opteron server, viewing the properties of a task inside a data flow was immediate up until this morning.

We just installed SP2, rebooted, and now you right-click on any task and it takes between 30 secs and 5 minutes before the context menu pops-up.

The server is 99% idle, most of the 16 Gigs of memory are idle as well.

View 1 Replies View Related

Working With A Package Is Extremely Slow

Nov 17, 2006

I have a package that reads the contents of 11 Excel files into various tables. Opening this package in the designer, or with DTExecUI is extremely slow. In both cases when I open the package is takes over 10 minutes to do anything. Visual Studio gives the "Visual Studio is Busy" message for 10 minutes and DTExecUI just hangs. DTExecUI actually hangs twice, once when opening the package and a second time when clicking "Execute" (totalling over 20 minutes). It seems like no matter how I try to run the package it will always hang for 10 minutes before running with no status message or anything. Once it runs it completes quickly with no errors.

The various tasks in the package are fairly simple, most being Source > Data Conversion > Destination.

Any suggestions?

View 4 Replies View Related

Exporting To Excel: Extremely Urgent

Mar 24, 2008



I have an Matrix report in which report output is completely numbers. That is fine but the problem is when i am trying to export it to Excel ,the data is exporting wih error:
Converting numbers stored as text.
i dont know why numbers are Exporting like text format.
please let me know whether it is problem with exporting in ssrs tool itself or else i need to change any properties in RDL file.
Note: This Error i am getting when i am using expression IIF(IsNothing(Fields!Parameter.value),"0",Fields!Parameter.value)

View 5 Replies View Related

Extremely Poor Performance On OLE DB Command Transform.

May 1, 2006

In one Data Flow Task (running by itself) I simply have a Raw File Source pushing rows to an OLE DB Command. This command executes an UPDATE command (UPDATE table SET field = ?, anotherfield = ? WHERE thisfield = ?) and performs extremely slow. It's possible to have 62K+ rows needing to be updated and it typically takes this task around 25 - 30 minutes to run.

Is there anything I can do to increase performance?
Are there any options other than the OLE DB Command to perform updates?

Thank you.

View 1 Replies View Related

Extremely Slow Client Connection To MSSQL

Jan 26, 2007

Hallo

i'm experiencing an extremely slow connection from a WXPP Sp2 client to a MSSQL2000 running on a W2k server. The client is running a VB6 application that connect with Windows authentication: every form requesting data opens with a long delay at the first launch; next attempts run normally fast.

In the same LAN there are some others identical clients, all running fine.

Every other network activity from that client is ok.

Where should i start to investigate from?

View 3 Replies View Related

Visual Studio Interface EXTREMELY Slow

Apr 7, 2006



Hi folks,

I'm working within VS2005/Business Intel studio environment. I've got one master package, which loads about 18 sub-packages as tasks.

After openin the master package (and waiting 5-10 minutes for the packages to open and validate), maneuvering within the IDE is nearly impossible, it is so slow. Context menus can take 30 seconds to open. Certian operations, like closing a window, seem to hang the environment.



Does anyone have any feedback about this kind of ide performance problem?



Thanks, Scott

View 10 Replies View Related







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