NOT EXISTS Versus NOT IN

Jan 30, 2004

I have two tables :

tableA
a_id (int)
value (varchar 255)

tableB
id (int)
a_id (int)
b_id (int)
c_id (int)
d_id (int)

Both these tables contain considerable amounts of rows, but over time tableA will end up containing orphaned values (i.e. the a_id is not used in tableB) and this problem cannot be rectified by setting, for example, cascade deletes.

To fix this problem I decided to write a simple stored procedure to purge all values in tableA where its a_id is not used in tableB :

DELETE FROM tableA WHERE a_id NOT IN (SELECT a_id FROM tableB)

Now although the following document relates to postgres :

http://archives.postgresql.org/pgsql-sql/2003-12/msg00174.php

I was interested to find out if I should be wary of using NOT IN in my query.

View 6 Replies


ADVERTISEMENT

@@ Versus @ In T-SQL

Apr 13, 2006

I'm sorry to be ignorant on this point. It seems trivial, but what's the difference between @@ and @ when using variables in T-SQL? I have a developer that always uses @@ for local variables and @ for reference variables (meaning variables declared as parameters for a stored procedure or function).

Is that purely stylistic? Is it a holdover from some previous version? Or is it a legitimate best practice that I've not seen before?

My google-shui is weak today; I found nothing when searching.

Regards,

hmscott

View 5 Replies View Related

SP2 Versus SP1

Feb 21, 2007

Do you need SP1 installed before installing SP2?


http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/servicepacks/sp2.mspx

View 1 Replies View Related

SQL - SP1 Versus SP2

Apr 13, 2007

Hi everybody. I am just confused. What is the difference between SQL SP1 and SP2 ? Can anyone explain further to me.

Thanks.
-Ron-

View 10 Replies View Related

IF NOT EXISTS (... - EXISTS TABLE : Nested Iteration. Table Scan.Forward Scan.

Sep 20, 2006

Hi,

This is on Sybase but I'm guessing that the same situation would happen on SQL Server. (Please confirm if you know).

I'm looking at these new databases and I'm seeing code similar to this all over the place:

if not exists (select 1 from dbo.t1 where f1 = @p1)
begin
select @errno = @errno | 1
end

There's a unique clustered in dex on t1.f1.

The execution plan shows this for this statement:

FROM TABLE
dbo.t1
EXISTS TABLE : nested iteration.
Table Scan.
Forward scan.
Positioning at start of table.

It's not using my index!!!!!

It seems to be the case with EXISTS statements. Can anybody confirm?

I also hinted to use the index but it still didn't use it.

If the existence check really doesn't use the index, what's a good code alternative to this check?

I did this and it's working great but I wonder if there's a better alternative. I don't really like doing the SET ROWCOUNT 1 and then SET ROWCOUNT 0 thing. SELECT TOP 1 won't work on Sybase, :-(.

SET ROWCOUNT 1
SELECT @cnt = (SELECT 1 FROM dbo.t1 (index ix01)
WHERE f1 = @p1
)
SET ROWCOUNT 0

Appreciate your help.

View 3 Replies View Related

SET Versus SELECT

Feb 12, 2007

Hello,

I have an Output parameter as follows:
@Feedback INT OUTPUT

I want to give it a value and return it.
What is the difference between using:

SELECT @Feedback = -1
RETURN @Feedback

And

SET @Feedback = -2
RETURN @Feedback

Thanks,
Miguel

View 19 Replies View Related

SSIS Versus DTS

Jun 20, 2007

Hello,



I wonder if anyone else out there has the same impression that I have: I find that DTS works much better than SSIS.



I find that DTS is so easy to use and reliable: it gets the job done and fast! On the other hand, SSIS seems to be so needlessly complex that it takes hours of troubleshooting just to get it to work, and sometimes it doesn't work at all. For example I have just spent hours trying to get SSIS to import a flat file with 300,000 rows. It just crashes and doesn't even give an error message so that one can fix it. On the other hand I have just now successfully accomplished the same task with DTS and it took me 5 minutes!



I honestly don't see a valid reason for using SQL Server 2005 instead of 2000. So far it's much more productive to use 2000.



I hope Microsoft can clarify this issue.



Regards,



Jerome Smith

View 8 Replies View Related

ADO.NET DATAVIEWS VERSUS SQL ENGINE

Jan 4, 2006

Hi All,
Any suggestions / views / help on below question would be welcomed.
I am building an asp.net 2.0 application with sql 2005 express as back end. My back end has 3 major tables which are:
tblArticles - saves basic info on articles posted by user (like articleid, title, short desc, rating, views, etc)
tblCategories - saves various categories and their hierarchies (id, parented, name, etc)
tblArticleCategories - saves info on which articles fall in which categories (like articleid, categoryid)
as of now, i am caching all rows from the first 2 tables, but i am in a bit of doubt for caching the third table (tblArticleCategories), although data in this table wont change very often and also this table will just have 2 columns and not many rows as well and this is a good target for caching,
but the reason I am in a bit of doubt to cache this table is, when my website visitor clicks on any category link in the category tree view, I need to use an inner join across all these 3 tables to locate and return all articles found in that particular category.
But I can do the same thing without hitting the database as I already have 2 of the required 3 tables in my cache, I can simply add the third table to my cache and then using the dataview objects rowfilter property on these 3 cached tables, I can very well get the appropriate results.
But I wonder which of the 2 methods would you prefer and suggest, I mean do you feel that just to save hits against the database, I am going to far and doing a lot of crap using the dataview (which might not be as efficient as sql engine) or you feel that the inefficiency of the dataview will still win compared to the cost of hitting the database for this
Thanks in advance, bye take care
Raj Chaudhari, Mumbai, India (MCAD.NET)
www.xtremebiz.biz

View 2 Replies View Related

Trigger Versus SQL Insert

Feb 16, 2006

Hello all,
I have table 'statistics' which holds information about another table, i.e. number of rows belonging to each user.
Would I be better off using a trigger after each insert to increment a certain row.
Or would I be better off selecting the data by means of an sql statement and updating the column whenever the statisitcs page is requested.
Does sql provide any methods which allow a column to count other rows or columns?
 

View 1 Replies View Related

SQL Server Versus Informix

Oct 25, 2000

Hi all,

Anyone here ever used the Informix database and can give me some differences between Informix and SQL.

One of our users is thinking about purchasing a COTS product that only supports an Informix database. I need to convince the user to evaluate other rival applications that can support SQL and need some arguments in favor of not going with Informix.

Any ideas appreciated,
Faustina

View 6 Replies View Related

ArcServe Versus BackupExec

Jun 21, 1999

We currently use CA ArcServe (ArcServe 6.5 Enterprise and Single Server Editions) to backup our Windows NT files and MS-SQL Server databases. We have experienced significant reliability issues with ArcServe. Many times we have found ourselves rebuilding a corrupt ArcServe Job (ArcServe’s backup schedule) database. One of our NT server occasionally NT bug checks when ArcServe is performing backups. Occasionally ArcServe Jobs incorrectly reschedule themselves. Sometimes the Jobs do not complete but stay executing, not performing any work, and to cancel them may require a lot of effort. The ArcServe job DB repair utility generally does not work. The user interface is lacking. For example, the job scheduling options are very limited. CA tech support for this product has been poor. Because we have issues with ArcServe stability we are now evaluating Veritas (formally Seagate) Backup Exec for NT. What are other people’s experiences with these 2 products?

View 1 Replies View Related

NEtwork Techs Versus DBA's

Jun 25, 2004

I gotta network tech that I work with from time to time. Hes gonna migrate a access database over to sql. He says it should be easy its a flat file can just do it through enterprise manager. I warned him that datatypes can become an issue (kinda have to know your db) he looked at me like I'm an idiot and proceeded to migrate the tables over to sql...Needless to say he got alot of error messages and is now totally confused. Now let me ask some experts who really Know Databases, do you ever have problems with Network Techs who think they know all

View 14 Replies View Related

Size Versus Space Available

Dec 7, 2005

We are planning hardware purchases (more is better). One of our databases is 131 gigs in size and has 45 gigs of 'space available'. I'm not a very experienced SQL Server person, but this seems like quite a bit of 'space available'

1) Is there a way to regulate the amount of 'space available'?
2) are there any rules of thumb for how 'space available' there should be?

Appreciate any feedback or help.

Ray

View 5 Replies View Related

SQL Server 2005 And 32-bit Versus 64-bit

Dec 14, 2006

Hi all,

we are about to purchase new database servers and have been offered a good deal on 64-bit Xeon machines. At present we run SQL 2000 on Windows Server 2003 both of which are 32-bit versions.

Is there any problem using our current 32-bit Server software on the 64-bit machines (apart from not being able to utilise its full power)? I'm assuming the SQL 2005 licenses are the same price regardless of 32-bit or 64-bit version. If we buy a 64-bit SQL Server version license are we going to get the best out of it on a 32-bit Windows Server edition?

tia - Matt

View 1 Replies View Related

Cursor Versus While Loop

Oct 29, 2007

I have always been told that Cursors create a lot of overhead and consume a lot of system resources. Is it faster to store the data in a temp table and loop through it by using Select Top 1 and Delete statements or by using a static, Forward-Only Cursor? Both ways store the data in TempDB, but doesn't the While Loop statement generate more IO's than the Cursor? In theory, I am thinking that the Cursor is better. Any info will be appreciated.

Thanks!!

View 2 Replies View Related

Nvarchar Versus Varchar

Oct 10, 2007

I have table with a field defined as nvarchar. I want to change it to varchar. I have a stored procedure which defines the parameter @strCall_desc as nvarchar(4000). Are there going to be ay problems with running this sp if I just change the field type as described.

TIA

View 6 Replies View Related

Update Versus Append

Jul 23, 2005

I have a database that is being used as sort of a reports datawarehouse. I use DTS packages to upload data from all the differentsources. Right now I have it truncating the tables and appending withfresh data. I was considering using updates instead and my question waswhich is more efficent?

View 3 Replies View Related

Update Versus Rebuild

Jul 23, 2005

Hi,Is there ever a case where a total rebuilt is preferable to anupdate? I am talking in the context of a data warehouse.Many thanksSam

View 1 Replies View Related

Return Versus Raiserror

Jul 20, 2005

I am trying to get a better understanding of when to use return (witha print statement) and when to use raiserror.* Both statements can be used with stored procedures while only returncan be used with functions.* With raiserror it is easy to have multiple errors thrown. (If boththe calling procedure and called procedure both try to handle error)Wow. Thought I could think of more. So that really leaves me with verylittle info on the proper use of these two statements.

View 2 Replies View Related

Sp_addextendedproperty Versus Sysproperties

Jul 20, 2005

I have been searching for a way to associate a description with acolumn name. I have come across multiple posts regarding thisquestion. Problem is that I have seen two different answers.One post mentioned using the undocumented system table namedsysproperties while other posts mentioned using thesp_addextendedproperty (and fn_listextendedproperty).Which one and why one over the other?Thanks.

View 1 Replies View Related

Joins Versus Relationships

Jul 20, 2005

If a database has relationships establshed between all of the tablesvia primary and foreign key constraints, why isn't is possible to makea SELECT statement across multiple tables without using a JOIN?If the system knows the relationsip schema already why are JOINSrequired?Thanks,HC

View 4 Replies View Related

SSIS Versus Coding.

Jun 25, 2007

This question probably overlaps a few different topic areas.



As I will be required to work with both Oracle and SQL Server I will be in a difficult position with SSIS(due to it's change in distribution).



Therefore I am having to look at alternatives.



With coding a can open a text file and parse it reasonably to my satisfaction. However getting the data into the database is incredibly slow.



I am using an Insert into for each line, which I am sure everone will shake their head over. This seems to be pretty slow even using transactions.



Is there any scope in using data tables or have the read on one thread and write on another.



Other than that is there an Oracle equivalent of SSIS which comes (probably get shot for asking that on a microsoft web site, but would probably get shot if I asked on Oracle forums as well).



In the past we had reasonable results in outputting to csv and then doing some sort of bulk insert, messy and irritating though this may be.



Any ideas on this area will be gratefully accepted.

View 2 Replies View Related

DT_I8 Versus DT_UI8

Mar 13, 2007

Can some one tell me in basic terms the difference between a signed and unsigned integer? When would you decided to use one over the other? I'm looking for it more in layman terms than a technical bit level discussion.

View 9 Replies View Related

Certificates Versus Keys

Jul 14, 2005

Hi,

View 3 Replies View Related

Authentication - Windows Versus Sql

Feb 23, 2008

Can anyone give me some advice on using authentication. What is the best way to go with a database on a server and why? And in order for you to use sql authentication, do you have to change the registry? I have seen some posts that seem to say you can only use it by changing the registry.

So if anyone can gie me the pro's and con's i would appreciate it.

Thanks
Jeff

View 7 Replies View Related

Ntext Versus Nvarchar

Feb 19, 2008

Hi,

my question concerns both desktop and device apps.

I'm using sql compact to store some data. I often have to store strings (descriptions, url, etc.) but I don't know when to use nvarchar or ntext.

Nvarchar needs to have a size limit, but I often set it to 8092 when I don't know the actual limit (urls can be very long !).
I fear Ntext because I suppose there is performances impact.



Is there any "rules" to help to choose which data type I'd use ?

Thanks,
Steve

View 5 Replies View Related

HTML Versus SSRS

Apr 10, 2008



Hi

we are currently working in a project where we need to create reports in Visual Studio 2005. the parent screen has a drop down which specifies the name of the report along with some other parameters. then the report is displayed in the same screen. now the issue is we are pretty much confused as to what to use to generate these reports? HTML or SSRS? the input fileds are only from date and to date and the displayed fileds are also not that many.

can some one please throw light on this?

Thanks,
Kumaraswamy

View 4 Replies View Related

A Question About Udf Versus Sp In A Specific Context...

Aug 21, 2006

Given the following objective:
1. Assume that I have a table that contains two fields: an auto-numbered id and an integer value2. Check to see if a record exists in a table based on a parameter query of the integer value3. If the record exists, return the record id4. If the record does not exist, insert a new record into the table (using the parameter value as data) and return the auto-numbered id of the new record
I can do each of these things as a sequence of individual steps, of course, but it seems to me that I ought to be able to do it with a single udf (or perhaps a specialized query) that would be more efficient. I couldn't find something like this in the beginning SQL Express books I have on hand and I also didn't find anything exactly on point on this newsgroup or a search of Google. However, I am sure the answer is 'out there' and I am hoping that someone can point me in the right direction. Thanks!
Duncan
 

View 4 Replies View Related

View Performance Versus SQL Statement

Nov 1, 2000

I have a complex(long) SQL statement inside of a stored procedure which feeds several variables from 2 tables. Something like

Select @var1, @var2, etc from
table1, table2 where
table1.id = table2.id

Is there any advantage to creating a view for this statement
and selecting from that, even though this resides in a stored procedure?

View 1 Replies View Related

ODBC Versus Security Problem

May 14, 1999

Ive got SQL Server 7.0 running in one domain and i'm trying to access it
from a workstation belonging to another domain. There is no trust
between the domains but well it worked fine with SQL 6.5.

Ive tried several combi nations with out success. My best result is to
get an error message followed by a login box every time the application,
spreadsheet etc... tries to access its data source.

Works fine from workstations belonging to the domain (SQL)

Any ideas ?

Thanks
Jan

We are what we repeatedly do. Excellence, then, is not an act, but a
habit. -- Aristotle

View 2 Replies View Related

Named Pipes Versus TCP/IP Sockets

Sep 25, 1998

We are having some problems using TCP/IP connection and was wondering what the benefits are to using this versus Named Pipes. The company that provides our software stated that this would improve performance but I do not see it and I am getting a lot of errors connecting. This also locks many of the users and I end up having to stop and start the database to clear the locks because there are so many. Would it be better to place the clients on Multi-protocol. It seems more powerful to use but I wanted to get some feedback from some people that may have dealt with this issue before.

Thanks,

View 1 Replies View Related

Enterprise Manager Versus Sp_spaceused

Jun 29, 1999

When comparing the data space available (Edit Database dialog within Enterprise Manager) to sp_spaceused, I occasionally generate numbers that have discrepancies.

Example
Enterprise Manager shows data space available = 160.43 MB
sp_spaceused (Unallocated space = 397 MB) less log space (200 MB) = 197 MB

Even after I run (sp_spaceused @updateusage = 'true'), the problem is not resolved. Are there any known issues with space being calculated incorrectly from within Enterprise Manager? Should I not rely on Enterprise Manager and stick with sp_spaceused to find out database usage? Are there any other methods which will resolve this problem? Any help would be appreciated.

Thanks,
Karl

View 3 Replies View Related

Tempdb Data Versus Log Size

Mar 20, 2007

Against my better judgement, we are using fixed allocations of tempdb on some of our servers. This is to deal with specific limitations of our applicaitons and hardware configuration that I'm not allowed to discuss in much detail.

The problem that I have is that the present plan is to configure the data file at around 18 Gb and the log file at around 2 Gb. This seems just plain wrong to me, but I haven't been able to find a formal recommendation that gives any relative sizing. I would expect to have about twice as much log as data space, especially for tempdb.

Does anyone know of a formal citation (preferably from Microsoft) that discusses this?

-PatP

View 2 Replies View Related







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