May 17, 2012 at 7:53 pm
DATE datatype contains no time component and is such better suited for storing things like DOB or a job start date (where time is not important).
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
May 18, 2012 at 2:06 pm
ssurekha2000 (5/17/2012)
IF EXISTS (SELECT 1 FROM E_TABLE1 WHERE eid =@eid)UPDATE E_TABLE1
SET FNAME=@FNAME,MNAME=@MNAME,LNAME=@LNAME,DOB=@DOB,Address=@Address, Gender=@Gender,Phone=@Phone,
Mobile=@Mobile,Email=@Email,
Where eid =@eid
ELSE
INSERT INTO E_TABLE1(eid,FNAME,MNAME,LNAME,DOB,Address,Gender,Phone,Mobile,Email)
VALUES (@eid,@FNAME,@MNAME,@LNAME,@DOB,@Address,@Gender,@Phone,@Mobile,@Email)
IF EXISTS (SELECT 1 FROM E_TABLE2 WHERE eid =@eid)
UPDATE E_TABLE2
SET desig=@desig,dept=@dept,DOJ=@DOJ
Where eid =@eid
ELSE
INSERT INTO E_TABLE2(eid,desig,dept,DOJ)
VALUES (@eid,@desig,@dept,@DOJ)
Hi
What i practice to do is using a flag in stored procedures as (last) additional input argument. My procedure would look like this:
Create Procedure spName
@arg1 type,
@arg2 type
@flag Smallint --for example, or it may be a Varchar or another type
...
If @flag=1
Begin
--Update code here
End
If @flag=2
Begin
--Insert code here
End
--and so on...
...
End
You will have to pass all arguments that are used by all options, but use only those necessary for the option @falg = value.
Regards
IgorMi
Igor Micev,My blog: www.igormicev.com
Viewing 2 posts - 16 through 16 (of 16 total)
You must be logged in to reply to this topic. Login to reply