Hi,
I'm using SQL Server 7.0. I have a table which has had some records double loaded into it and some triple loaded. I need to delete all instances of a record except for 1. The records are identical with no unique identifier. Here is what I'm talking about.
Currently in the table is:
ID DATE STATUS
1 07/07/2000 D
1 07/07/2000 D
1 07/07/2000 D
2 07/07/2000 A
2 07/07/2000 A
I was just doing a table import task (right click database name/Tasks/Import Data), not knowing my boss had just loaded the same file. it did not warn me that the table currently existed. It just appended the same information to the same table, doubling it. I fixed that one, but, it seems that I might have done this myself in the last couple of weeks, and I'd like to find that table, and there have been a LOT of table loads.
I'm thinking I could get the difference between tables by comparing:
select distinct count(*) from tblname against select count(*) from tblname
But how do I incorporate this into some sort of proc that will go through all the tables and let me know where the issue is? I'm swamped and don't have the time to go through each table manually.
I have code that shows me row counts, and have been able to eliminate a few tables from contention, as they are loading monthly data that should only increase minorly month to month, so, no double jumps there.
I am performing a series of calculations where accuracy is very important, so have a quick question about single vs double precision variables in SQL 2008.
I'm assuming that there is an easy way to cast a variable that is currently stored as a FLOAT as a DOUBLE prior to these calculations for reduced rounding errors, but I can't seem to find it.
I've tried CAST and CONVERT, but get errors when I try to convert to DOUBLE.
For example...
SELECT CAST(1.0/7.0 AS FLOAT) SELECT CONVERT(FLOAT, 1.0/7.0)
both give the same 6 decimal place approximation, and the 6 decimals make me think this is single precision.
But I get errors if I try to change the word FLOAT to DOUBLE in either one of those commands...
Every night we connect to a remote server using Linked Server and copy details from that database to a loading table, then load it into the 'real' table in our own environment. The remove database we load it from has indexes/primary keys that match the 'real', however the 'loading' table itself does not have any indexes or primary keys, both are SQL Server 2005 machines.
In the loading table we first of all truncate it then do a select insert statement from the remote server, then we then truncate the 'real' table and load iit from the 'loading' table.
The issue is when we attempted to load it into our 'real' table from our loading table there was a duplicate row, and our process failed with a Primary Key violation.
I checked the source with does have the same primary key's in, it did not contain a duplicate row and I checked the loading table and that did contain a duplicate row.
My question this is in what circumstances this could happen ?
Need to find a way to do this. I have two tables, One with codes i.e. S,R,T and other with transactions looks like this:
Transaction table Emp Trans Tot... X55677 S 8 X55677 R 2 C22887 S 4 C22887 T 3 F66889 S 9 F66889 R 4 F66889 T 3
Code table S R T
Not sure if the code table even helps. What I want to do is show all three transactions for each employee even if they don't have any (would be zero) like so...
Emp Trans Tot... X55677 S 8 X55677 R 2 X55677 T 0 C22887 S 4 C22887 T 3 C22887 R 0 F66889 S 9 F66889 R 4 F66889 T 3
How can I get to this. I'm sure there must be a solution already posted for something like this but I'm not sure what to search for.
l've written a cursor to koop through a table and then insert the last 100 records into a table.Reason why l want the last 100 records is to monitor and log the last 100 trans avery hr or so.
-- Declare the variables to store the values returned by FETCH. SET ROWCOUNT 100 DECLARE @customer_No char(15), @loan_No char(12), @date_Issued datetime , @maturity_Date datetime , @status int
DECLARE loan_cursor CURSOR FOR SELECT customer_No, loan_No, date_Issued, maturity_Date, status
FROM loan
OPEN loan_cursor
-- Perform the first fetch and store the values in variables.
FETCH NEXT FROM loan_cursor INTO @customer_No, @loan_No, @date_Issued , @maturity_Date, @status,
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0 BEGIN
-- This is executed as long as the previous fetch succeeds. FETCH NEXT FROM loan_cursor INTO @customer_No , @loan_No , @date_Issued , @maturity_Date , @status END
CLOSE loan_cursor
DEALLOCATE loan_cursor;
insert into Loan1 (customer_No, loan_No, date_Issued , maturity_Date , status )
select @customer_No, @loan_No, @date_Issued, @maturity_Date, @status FROM loan ORDER BY date_Issued desc;
if l want to commit the transactions after every thousand how would l build it into the script?
Begin Transaction
Select a.AccountNo, a.TransactionNo, a.TransactionAmount, a.TransactionDate Into dbo.test1
From Trans_May_14Aug2002 a,Reds_JuL_Trans_08Jul2002 b
Where ltrim(rtrim(left(a.AccountNo,20)))=ltrim(rtrim(lef t(b.AccountNo,20))) AND ltrim(rtrim(left(a.TransactionNo,20)))=ltrim(rtrim (left(b.TransactionNo,20))) AND a.TransactionAmount=b.TransactionAmount AND a.TransactionDate =b.TransactionDate AND ltrim(rtrim(left(a.Product,20))) IN ('PR060','PR061','PR091', 'PR096','PR111','PR121', 'PR122')
AND ltrim(rtrim(left(a.Transactiontype,20))) IN ('TR001','TR003','TR011', 'TR013','TR027','TR028', 'TR042','TR043','TR044', 'TR045','TR998','TR999')
AND ltrim(rtrim(left(a.journaltype,20))) NOT IN ('JT000','JT720','JT721', 'JT722','JT723','JT725', 'JT726','JT729','JT730', 'JT737','JT738','JT739', 'JT740','JT743','JT746', 'JT751')
OR ltrim(rtrim(left(a.JournalType,20))) IS NULL
AND a.TransactionDate > '2002-04-30'AND b.transactionDate < '2002-07-01'
I'm trying to export around 115,000 rows from ms sql 2000 into Excel 2000, using the manual process. I just need this one time dump.
I am able to successfully export around +- 65,000 rows, but the operation fails after that.
I need to be able to get all the rows out, so using TOP obviously doesn't work.
Is there some "version" or modified way to use TOP to get...say, rows 65,000 to 90,000 then 90,001 to 115,000 ?
This would'nt be an issue if the db I'm working with was MySQL...I'd just use the LIMIT function and pull out 3 different chucks. Is there anything similar to LIMIT...or something converse to TOP in MS SQL? Or perhaps another way to dump the table then export it all (or in portions) into Excel?
Help! Surely this has happened to others before me. A new customer wants to send updates in a fixed-width txt file in which master and detail rows alternate.
How do you do this?
Do you: 1) Painfully muck around with 100,000 rows in the .txt file first--split it into 2 files, one for master records and one for detail records and then process? If so, what do you use? I'd probably hack at it with a VB Script module in a DTS package.
or
2) Is there a way to feed it into 2 tables where rows starting with x go to one table and rows starting with y go to another?
The plan was to use a fast and dirty DTS package to shove this stuff into a table (probably 2 but we might just toss the stuff we don't need and put in in one) but I'd like some advice on how to proceed.
I need to count the records in a table with a datetime field equal to system datetime. It looks like it is trying to match time also since time is in field too. I just want to match date only. My sql is below. Does anyone have some suggestions on how to handle this? Date from code
DateTime todaydt = DateTime.Now;
Table Data format
[cal_str_tm] [datetime] not null, Data in cal_str_tm field - 3/27/2008 9:43:16 PM
Thanks, Ron
ALTER PROCEDURE SP_DpCount
(
@todaydt datetime
)
AS
SELECT @total = COUNT(cal_int_id)
from dpcalldtl
where (cal_callstat != 'COMPLETED' and cal_str_tm = @todaydt)
I use a redirect row method for error of OLE DB Destination For sqlServer2005.
For some resone even though only 1 record has error and should be redirect, all the record in the current batch (I think depending on the "maximum insert commit size") are redirect. the only way for me to get the exact bad record is to set the above parameter to 1, but then it takes hours to run the package.
also I always get the same error in the errorCode column - " -1071607685"
I'm running SQL Server Agent services and SQL Server Integration services under same DomainUser account and the same DomainUser account is also having sysadmin rights in sql server.
And below is the SQLAgent.OUT file details which I'm getting while running the SSIS from SQL Agent job.
[100] Microsoft SQLServerAgent version 9.00.1399.06 (x86 unicode retail build) : Process ID 4012 [101] SQL Server MachineNameXYZ version 9.00.1399 (0 connection limit) [102] SQL Server ODBC driver version 9.00.1399 [103] NetLib being used by driver is DBNETLIB.DLL; Local host server is [310] 4 processor(s) and 3072 MB RAM detected [339] Local computer is MachineNameXYZ running Windows NT 5.2 (3790) Service Pack 1 [432] There are 11 subsystems in the subsystems cache [125] Subsystem 'ActiveScripting' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'CmdExec' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'Snapshot' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'LogReader' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'Distribution' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'Merge' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'QueueReader' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'ANALYSISQUERY' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'ANALYSISCOMMAND' could not be loaded (reason: The specified module could not be found) [125] Subsystem 'SSIS' could not be loaded (reason: The specified module could not be found) [364] The Messenger service has not been started - NetSend notifications will not be sent [129] SQLSERVERAGENT starting under Windows NT service control [260] Unable to start mail session (reason: No mail profile defined) [396] An idle CPU condition has not been defined - OnIdle job schedules will have no effect [LOG] Step 1 of job 'TestJob' (0x4A197E88EAD5134581A35132A546414C) cannot be run because the SSIS subsystem failed to load. The job has been suspended [LOG] Unable to read local eventlog (reason: The parameter is incorrect) [LOG] Unable to read local eventlog (reason: The parameter is incorrect) [LOG] Step 1 of job 'TestJob' (0xE412C2AB10C7A34B87F5DFC8CFD978CA) cannot be run because the SSIS subsystem failed to load. The job has been suspended [LOG] Unable to read local eventlog (reason: The parameter is incorrect)
have a dts package that does txt -> sql server. i have 200 txt files with the same exact format.
just want to know if i can write a SP passing a parameter that loads this txt files. because i dont wanna create 200 packages or 200 sources to load 200 txt files.
say: exec SP_loadTXT txt1
or should i use bulk insert?
any approaches are fine. any suggestions are fine too.
I'm doing some performance reviews and wish to know what tables SQL haspinned in memory and which ones have are loaded through usage ...Is there a way ?Thanks,Craig
[MS SQL Server 7]We load a table from a text file using Data Transformation Services. Thesource file is already sorted by primary key order.After the DTS load, the default retrieval order on the target table (select* from targettable) appears to be random. I know that theoretically theretrieval order from a SELECT statement isn't guaranteed, but this is thefirst time that I've actually had a default retrieval not follow theprimary key order in the table. I'm thinking that what we're seeing is thephysical storage order of the rows in the table, which have been somewhatscrambled by the way that DTS loads a text file (probably some I/Ooptimization).Is there any way that we can get DTS to load the table in the order thatthe rows appear in the text file (assuming that's what our problem is)?The Project Lead really doesn't like the fact that the default retrievalorder isn't following the primary key.Regards,Lyle H. Gray
I have created a dts on my Sql server. which gets the data from my log file and insert into my sql 2005 table. In dts i am using 'Flat File Source' and 'SQL Server Destination'. When i execute this through 'SQL Server Business Intelligence Development Studio' it works good.
But when i execute this through my c# code from my web server, it throws me an error 'The specified package could not be loaded from the SQL Server database.'
I have created a package and when i was trying to configure a flat file destination, i am getting the following error:
===================================
The component could not be added to the Data Flow task. Could not initialize the component. There is a potential problem in the ProvideComponentProperties method. (Microsoft Visual Studio)
===================================
Error at Extract Test Flat File [DTS.Pipeline]: The module containing "component "" (245)" cannot be located, even though it is registered.
===================================
Exception from HRESULT: 0xC0048021 (Microsoft.SqlServer.DTSPipelineWrap)
------------------------------ Program Location:
at Microsoft.SqlServer.Dts.Pipeline.Wrapper.CManagedComponentWrapperClass.ProvideComponentProperties() at Microsoft.DataTransformationServices.Design.PipelineTaskDesigner.AddNewComponent(String clsid, Boolean throwOnError)
What SSIS components must be loaded onto the server?
To run an SSIS ETL program, exactly what executable, components, programs, etc. must reside on the server that will be running the program. Our developers write an test their ETL programs locally, on their desktops or laptops, but must upload the scripts to the production server for execution. Obviously, they are not going load Visual Studio and SQL 2005, etc. up to the server just to run the scripts (tho SQL 2005 may be on the same box as one of the DB engines used for ETL).
Is there a way to handle an event when the report viewer has completed loading the report? I have handled the report viewer load event but also want to handle an event for when it has completed loading.
I am wanting this because the "report is being generated" message is far off of the screen when I use a large report viewer.
So, on page load I simply make a textbox visible that says "report is being generated". When it completes generating the report, I want it to make that message invisible.
The disposed and unload events don't seem to handle this correctly.
I'm trying to start the generic query designer and i get this error. I have no idea what is wrong, but I know I'm using Visual Studio 2005 V 8.050727.42 .net Framework 2.050727 SSRS Designers v 9:00.3042.00
I am getting message while modifying one table in SSMS like "Table '?' could not be loaded. Column '?' does not exist" . Howevery particular column exist in table and even i am able to modify it with T-SQL.
This is working fine. Assembly is loaded and WebControl is created.
But as my Custom WebControl tries to access SQL Server database, i get a "Must declare the variable '@id'" while executing an ExecuteScalar() from a SqlCommand.
Code in my WebControl was perferctly functioning before converting it from a UserControl (.ascx) to Custom WebControl. Parameter '@id' is correctly declared in my query. If i don't use SqlParameters, everithing works fine...
Hello, I'm using a multipart/form-data upload to put an image into SQLServer, and it appears to be working, but I'm unable to display theimage. All I'm getting is the text of the URL we're on in Firefox anda missing image icon in IE! Any ideas why this isn't working? Here'sthe image upload code:Dim intImageSize As Int64Dim strImageType As StringDim ImageStream As StreamintImageSize = Picture.PostedFile.ContentLengthstrImageType = Picture.PostedFile.ContentTypeImageStream = Picture.PostedFile.InputStreamDim ImageContent(intImageSize) As ByteDim intStatus As IntegerintStatus = ImageStream.Read(ImageContent, 0, intImageSize)'make connection, write SPs, open connection, etc.TrydbComm.ExecuteNonQuery()Connect.closeCatch SQLexc As SqlExceptionResponse.Write("Insert Failed. Error Details are: " &SQLexc.ToString())End Try--------------And now the display code:'make connection, then SELECT Image, Imagetype FROM Pets WHERE[User]=@user AND Petn=@petn'stored proceduresDim Reader As SqlDataReaderReader = dbComm.ExecuteReader(CommandBehavior.CloseConnecti on)If Reader.read=True ThenResponse.ContentType = Reader(1)Response.BinaryWrite(Reader(0))ElseEnd IfReader.closeConnect.close----------------------------Thanks.
I have to archive the Flat files after they are loaded into an archive folder with a Date time stamp on the folder in the format mmddyyyyhhmmss what task should i use in ssis to complete this and can i do this task for multiple files in the directory, how should i configure such that all files are archived and placed in one directory with a current timestamp, Please Provide me with a solution
I am using a XML source and an oldedb destination to load an XML file into a database, the XML and corresponding XSD are provided by a different system and I dont have any control on them.
In the data flow I can see all the tables in the schema and I can map the columns, however when I run the package it validates fine, and then completes without going into the execution mode, its all green but doesnt load any data. Its weird and I cannot figure out if it is an XML or XSD problem, any idea?
I am trying to find a way of creating my Repoting Services reports of automatically refreshing once our ETL load has completd. I have created a process that creates a file is a particular directory once the data has completed loading however I am unsure how to make the report look for this file and then refresh the report.
I have create few Mannaged SP which acces some external resources like closing and starting some windows process.. the assembly is assigend unsafe security level
all the processes are started from sqlserver.exe service and are allowed to interact with desktop
these SPs are called frequently
Problem... a very few times sql server is crashed..
does mannaged SP load app domain each time they are called?
what possible reason can be?
I am not exactly clear about the reson .. so I decided to post over here ..
while working on deployment to production server of an SSIS project, I have noticed that development priject has "disappeared" from my development machine which, obviously, was not my intention, at all. I now get the error prompt saying this:
what am I suppose to do in order to RESTORE it on devel machine like it used to be?
Hi, I am trying to create a maintenance plan on an MSX server and push it out to a TSX server. When I try to run the job on the TSX server it goes into suspended status.
If I look in the SQLAGENT log I see the following error
2008-04-30 15:04:11 - + [125] Subsystem 'SSIS' could not be loaded (reason: This function is not supported on this system) 2008-04-30 15:08:19 - + [125] Subsystem 'SSIS' could not be loaded (reason: This function is not supported on this system) 2008-04-30 15:09:28 - + [125] Subsystem 'SSIS' could not be loaded (reason: This function is not supported on this system) 2008-04-30 15:27:36 - ! [LOG] Step 1 of job 'SystemDatabases.Back Up Database (Full) (Multi-Server)' (0x97394B08F6599040A18D93367FBDB5F7) cannot be run because the SSIS subsystem failed to load. The job has been suspended 2008-04-30 15:35:13 - + [125] Subsystem 'SSIS' could not be loaded (reason: This function is not supported on this system) 2008-04-30 15:50:27 - ! [LOG] Step 1 of job 'SystemDatabases.Back Up Database (Full) (Multi-Server)' (0x97394B08F6599040A18D93367FBDB5F7) cannot be run because the SSIS subsystem failed to load. The job has been suspended
my sql info is Microsoft SQL Server 2005 - 9.00.3239.00 (X64) Copyright (c) 1988-2005 Microsoft Corporation Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2)
I'm attempting to install sql server developers edition on windows server 2003. When I start the install I get a message to upgrade to sp2 or higher after the install is completed.
Then I get the following:
Execution cannot continue as the language dependent resource file c:DOCUME~1MTIDMA~1LOCALS~1Temp1SqlSetupBinResources1033sqlsui.RLL could not be loaded.