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
ADVERTISEMENT
Nov 29, 2007
Far below (in section "original 3 steps"), you see the following:1. a temp table is created2. some data is inserted into this table3. some of the inserted data is removed based on a join with the sametable that the original select was made fromIn my opinion, there is no way that the join could produce more rowsthan were originally retrieved from viewD. Hence, we could get rid ofthe DELETE step by simply changing the query to be:INSERT INTO #details ( rec_id, orig_corr, bene_corr )SELECT rec_id, 0, 0FROM viewDWHERE SOURCE_SYS NOT IN ( 'G', 'K' )AND MONTH( VALUE_DATE_A8 ) = MONTH( @date )AND YEAR( VALUE_DATE_A8 ) = YEAR( @date )AND INMESS NOT LIKE '2__' ---- the added line===== original 3 steps (mentioned above) =====CREATE TABLE #details (rec_id UNIQUEIDENTIFIER PRIMARY KEY NOT NULL,orig VARCHAR(35) NULL,bene VARCHAR(35) NULL,orig_corr TINYINT NULL,bene_corr TINYINT NULL)INSERT INTO #details ( rec_id, orig_corr, bene_corr )SELECT rec_id, 0, 0FROM viewDWHERE SOURCE_SYS NOT IN ( 'G', 'K' )AND MONTH( VALUE_DATE_A8 ) = MONTH( @date )AND YEAR( VALUE_DATE_A8 ) = YEAR( @date )DELETE dFROM #details dJOIN viewD v ON ( d.rec_id = v.rec_id )WHERE INMESS LIKE '2__'
View 1 Replies
View Related
Jun 1, 2006
I am trying to look up records by the first letter of the last name in SQL Express ADO recordsets.
"Select * from people where people.lastname like 'a%'"
works correctly. (a*) works also.
ptRs.movefirst
PtRs.Find "lastname LIKE 'a%'", 0, adSearchForward
Does not work, does not find anything, but if I use 'a %' ('a<space>%') it finds the first last name starting with a.
Why does a% not work. Can you not use wild characters in Find Statements in SQL Express?
View 3 Replies
View Related
Aug 9, 2013
Why would I use a left join instead of a inner join when the columns entered within the SELECT command determine what is displayed from the query results?
View 4 Replies
View Related
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
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
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
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
View Related
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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