Procedure require in DB:i want insert records in temp table(if that records are not exist in temptable)
i have one "LOGTABLE" having 3000 records, in this table daily 3-4 records will be inserted.this table have 11colums no primary key columns.
i created another temp table as "LOGTABLEMONITOR". (copied from "LOGTABLE" having 3000 records)
i am expecting which are inserting daily 3-4 records in "LOGTABLE" will be inserting temp table "LOGTABLEMONITOR" (if that 3-4 records are not exist in "LOGTABLEMONITOR")
SELECT <columns>
FROM LOGTABLE
EXCEPT
SELECT <columns>
FROM LOGTABLEMONITOR;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence
Similar Messages
-
HOW TO create a temp table or a record group at run time
i have a a tabular form and i dont want to allow the user entering duplicate
records while he is in insert mode and the inserted records are new and not exsisting in the database.
so i want to know how to create a temp table or a record group at run time to hold the inserted valuse and compare if they are exsiting in previous rows or no.
please help!As was stated above, there are better ways to do it. But if you still wish to create a temporary block to hold the inserted records, then you can do this:
Create a non-database block with items that have the same data types as the database table. When the user creates a new record, insert the record in the non-database block. Then, before the commit, compare the records in the non-database block with those in the database block, one at a time, item by item. If the record is not a duplicate, copy the record to the database block. Commit the records, and delete the records in the non-database block. -
Hi All,
im having trouble few days now , i hope someone can give me a lead here.
i have a director mx file written in arabic, i open it in Director 11.5, the file behave strangely, very slow publishing process, very slow access to the xtra list.
after publishing (shockwave and html), i open the html, the preloaded start to run but i can see its not reaching 100%, after a while i get the error massage:
"This application required an Xtra (ActiveX...) that either does not exist or failed..." and firebox or IE crashes.
In the movie extra list (Modify menu) i can see all extras, and all have "download if needed", but in ActiveX the "download if needed" grays out. i have no idea why
things i try with no success:
uninstall and reinstall shockwave player
check the same file in another machine
exclude and include xtras in Publish Settings > Files
add activex.x32 from other places
Hope for good news
Win Xp sp3
Thanks
ShayIn the movie extra list (Modify menu) i can see all extras, and all have "download if needed", but in ActiveX the "download if needed" grays out. i have no idea why
Because AX controls aren't SW-safe. You will have to redesign your file to remove the ActiveX control if you want it to run in a browser. -
Populating a temp table with multiple records.
I want to populate a temp table with a a set of recs. This table will be used for
crossing/joining with my other tables to pull out data.
ie:
Main table (loc)contains these fields -> county,permit,utme,utmn
Temp table ( tmpid) contains these fields -> countytemp, permittemp
So I will be doing a statement like this once my temp table is populated.
Select l.county,l.permit,l.utme,l.utmn from loc l,tmpid t where l.county=t.countytemp and l.permit=t.permittemp;
So this temp table will basically be a list of ids that can range from a few recs to several hundred.
I want to know is there is way I can poplulate/repopulate it easily using sqlPlus/other by reading in a Ascii file
from client PCs. (besides SQL loader).HI
let me explain my requirement first,
i need to populate my block with the results from the following sql
SELECT * from contactdet where
(Month=12 and TrType='MTM' and FinYr='04-05' and Userid='SA009' and Clcode='SB001')
UNION
SELECT * from contactdetSUM where (Clcode='SB001' AND CSCODE='AB001')
Pease note. the where clauses i have put are different in each table and my requirement is
the constants values i have put in where clause should be variable (ie. i should be able to put variables like :clcode or so)
I tried us using Query data source type as 'FROM clause query' but it does not allow me to put variables in where clause.
Is there any way out i can do this ? Please help me
Regards
Uday -
SSIS package takes longer time when inserting data into temp tables
querying records from one server and inserting them into temp tables is taking longer time.
are there any setting in package which enhance the performance .will local temp table (#temp ) enhance the performance ..
If you're planning to use # tables in ssis make sure you read this
http://consultingblogs.emc.com/jamiethomson/archive/2006/11/19/SSIS_3A00_-Using-temporary-tables.aspx
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
I want the iphone 4 ios supports 8 be kind are not bad not let oblivion because the iphone 4 is as good as the iphone 4s
iOS 8 requires a dual-core processor; the iPhone 4S has that, but the iPhone 4 doesn't.
(117890) -
When I connect my iPod touch to my computer, I have a list of Events on my iTunes-iPod-Photos. I want to erase these Events. However, the photos are NOT on my MacBook Air-iPhoto. When I check one of the Events and then hit Apply, the photos appear on my iPod. And one last thing: When I connect the iPod and open iPhoto, iPhoto tries to load New Photos (I think), but nothing happens. Any ideas?
Resolved.
-
how do I change system settings so that users are not required to enter the mac's admin pw in order to join a wifi network?
Right now my macbook pro requires an admin password before connecting to a new wifi network. In other words when a user that is not an admin tries to connect to a new wifi network the pop up displays indicating that it is locked and an admin password is required.
Is there a way to remove this restriction so that a non admin can connect to wifi without the mac's admin password.You can enable / disable this option in System Preferences:
System Preferences > Network > Wi-Fi > Advanced > Wi-Fi tab > Require administrator authorization to: Change networks -
I have an iPhone, an iPad, 2 iPad mini's and 2 iPod Touch's that all share the same apple id. I want to separate the iPhone so that texts are not seen on the other devices but I still want them to have the iMessage ability. How do I do that?
Not sure if you can have 2 Apple ids contact Apple.com/I'd You may to set IPhone up as new with a different Apple ID & password. Bsydd uk
-
How to insert some records in one table and some records in another table
Interview question
how insert records in two tables by using trigger
CREATE or REPLACE TRIGGER Emp_Ins_Upd_Del_Trig
BEFORE delete or insert or update on EMP
FOR EACH ROW
BEGIN
if UPDATING then
UPDATE emp2
SET
empno = :new.empno,
ename = :new.ename
--, job = :new.job
--, mgr = :new.mgr
--, hiredate = :new.hiredate
, sal = :new.sal
--, comm = :new.comm
--, deptno = :new.deptno;
sdate = :new.sdate,
edate = :new.edate
end if;
if INSERTING then
INSERT INTO emp2
VALUES
( :new.empno
, :new.ename
--, :new.job
--, :new.mgr
--, :new.hiredate
, :new.sal
--, :new.comm
--, :new.deptno
new.sdate,
new.edate);
end if;
if DELETING then
DELETE FROM emp2
WHERE empno = emp2.empno;
end if;
END;
it is working fine but he wants to insert some specific litimit on one table and some specified limit of records in one ..
In this senerio can i insert records by use count of records...
please help me..Can you be more specific on the "Limit"
Conditional insert can be used in this case. -
Insert into a temp table is to slow
i'd like to know why if i created a temp table out of my procedure the insert into it get slower than if i create that temp table inside my procedure. follows an example:
create table #Test (col1 varchar(max))
go
create proc dbo.test
as
begin
truncate table #Test
insert into #Test
select 'teste'
FROM sys.tables
cross join sys.columns
end
go
exec dbo.test
go
create table #Test2 (col1 varchar(max))
go
truncate table #Test2
insert into #Test2
select 'teste'
FROM sys.tables
cross join sys.columns
At test, we get duration 71700, reads 45220, CPU 26052 At test2, we get duration 49636, reads 45166, cpu 24960
best regardsThere should be no difference.
You would have to repeat the test you designed a few times to take readings and then reverse the order.
BOL: "
Benefits of Using Stored Procedures
The following list describes some benefits of using procedures.
Reduced server/client network traffic
The commands in a procedure are executed as a single batch of code. This can significantly reduce network traffic between the server and client because only the call to execute the procedure is sent across the network. Without the code encapsulation provided
by a procedure, every individual line of code would have to cross the network.
Stronger security
Multiple users and client programs can perform operations on underlying database objects through a procedure, even if the users and programs do not have direct permissions on those underlying objects. The procedure controls what processes and activities
are performed and protects the underlying database objects. This eliminates the requirement to grant permissions at the individual object level and simplifies the security layers.
The EXECUTE AS
clause can be specified in the CREATE PROCEDURE statement to enable impersonating another user, or enable users or applications to perform certain database activities without needing direct permissions on the underlying objects and commands. For example,
some actions such as TRUNCATE TABLE, do not have grantable permissions. To execute TRUNCATE TABLE, the user must have ALTER permissions on the specified table. Granting a user ALTER permissions on a table may not be ideal because the user will effectively
have permissions well beyond the ability to truncate a table. By incorporating the TRUNCATE TABLE statement in a module and specifying that module execute as a user who has permissions to modify the table, you can extend the permissions to truncate the table
to the user that you grant EXECUTE permissions on the module.
When calling a procedure over the network, only the call to execute the procedure is visible. Therefore, malicious users cannot see table and database object names, embed Transact-SQL statements of their own, or search for critical data.
Using procedure parameters helps guard against SQL injection attacks. Since parameter input is treated as a literal value and not as executable code, it is more difficult for an attacker to insert a command into the Transact-SQL statement(s) inside
the procedure and compromise security.
Procedures can be encrypted, helping to obfuscate the source code. For more information, see SQL Server Encryption.
Reuse of code
The code for any repetitious database operation is the perfect candidate for encapsulation in procedures. This eliminates needless rewrites of the same code, decreases code inconsistency, and allows the code to be accessed and executed by any user or application
possessing the necessary permissions.
Easier maintenance
When client applications call procedures and keep database operations in the data tier, only the procedures must be updated for any changes in the underlying database. The application tier remains separate and does not have to know how about any changes
to database layouts, relationships, or processes.
Improved performance
By default, a procedure compiles the first time it is executed and creates an execution plan that is reused for subsequent executions. Since the query processor does not have to create a new plan, it typically takes less time to process the procedure.
If there has been significant change to the tables or data referenced by the procedure, the precompiled plan may actually cause the procedure to perform slower. In this case, recompiling the procedure and forcing a new execution plan can improve performance.
LINK: http://technet.microsoft.com/en-us/library/ms190782.aspx
Kalman Toth Database & OLAP Architect
Free T-SQL Scripts
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
How to retrive one table records into another table by multiple records
how to retrive table X records into another table Y by multiple records (means at once i want display 10 records) in form 6i .
when i am written cursor it is ftching only one record.But i want to display all records at once.
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae WHERE PROTOCOL_NO='KP229';
Begin
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Hi,
Make sure the cursor is in the detailed block. For that use 8GO_BLOCK* built-in. So the code will be
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae;
Begin
GO_BLOCK('<detailed_block_name>');
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Regards,
Manu.
If my response or the response of another was helpful or Correct, please mark it accordingly -
I have a new computer, Windows 8. My old laptop died and I used to Sync my iPad and iPhone on that device. Now I want to update, the new desktop computer states that I do not have permission. How do I change permissions to this new computer?
Did you authorize it?
-
Query is taking too much time for inserting into a temp table and for spooling
Hi,
I am working on a query optimization project where I have found a query which takes hell lot of time to execute.
Temp table is defined as follows:
DECLARE @CastSummary TABLE (CastID INT, SalesOrderID INT, ProductionOrderID INT, Actual FLOAT,
ProductionOrderNo NVARCHAR(50), SalesOrderNo NVARCHAR(50), Customer NVARCHAR(MAX), Targets FLOAT)
SELECT
C.CastID,
SO.SalesOrderID,
PO.ProductionOrderID,
F.CalculatedWeight,
PO.ProductionOrderNo,
SO.SalesOrderNo,
SC.Name,
SO.OrderQty
FROM
CastCast C
JOIN Sales.Production PO ON PO.ProductionOrderID = C.ProductionOrderID
join Sales.ProductionDetail d on d.ProductionOrderID = PO.ProductionOrderID
LEFT JOIN Sales.SalesOrder SO ON d.SalesOrderID = SO.SalesOrderID
LEFT JOIN FinishedGoods.Equipment F ON F.CastID = C.CastID
JOIN Sales.Customer SC ON SC.CustomerID = SO.CustomerID
WHERE
(C.CreatedDate >= @StartDate AND C.CreatedDate < @EndDate)
It takes almost 33% for Table Insert when I insert the data in a temp table and then 67% for Spooling. I had removed 2 LEFT joins and made it as JOIN from the above query and then tried. Query execution became bit fast. But still needs improvement.
How I can improve further. Will it be good enough if I create Indexes on the columns for the temp table and try.or what If I use derived tables?? Please suggest.
-PepHow I can improve further. Will it be good enough if I create Indexes on the columns for the temp table and try.or what If I use derived tables??
I suggest you start with index tuning. Specifically, make sure columns specified in the WHERE and JOIN columns are properly indexed (ideally clustered or covering, and unique when possible). Changing outer joins to inner joins is appropriate
if you don't need outer joins in the first place.
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
How create a record type and a pl/sql table of that record type in database
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
Regardsuser576726 wrote:
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
RegardsRECORD type is supported only in PL/SQL for SQL you need to use OBJECT type.
Maybe you are looking for
-
Windows 8.1 update problem
I tryed to restore my computer (HP Spectre XT 15-4010nr) to certain date and I got a blank screen, I didn't know what to do so I used the recovery media, know I can't install windows 8.1 in the machine, I did all the updates from windows an the HP w
-
ARD Connection failed when trying to control everything else works
I have: a few macs verifying hard ware specs G4,G5, Intel etc. All with the latest updates and fixes. I have ARD on 3. I have one rogue iMacG5 20 inch. I have ARD running on this mac and it works 100%, I can control copy everything to any target comp
-
Keynote 6.2.2 will not open a keynote file created in 6.2.2
I was sent a keynote file by a work colleague and we both have Keynote 6.2.2 on our MacBook Pro's. My MacBook will not open the file sent by my colleague even though it was created in version 6.2.2 I get an error message saying I need to download the
-
Getting errors in LR 6 after importing MOV files
Hi, LR 6 newbie here after using Apple's Aperture. It seems that none of my MOV files are working after importing them from Aperture. Any suggestions what should I do? I've tried purging the cache in Preferences->File handling but no luck so far. Rea
-
I have created a Java application with a GUI interface. Is there any way to invoke the application without having wht Windows command window coming up allow with the GUI interface