Showing posts with label department. Show all posts
Showing posts with label department. Show all posts

Friday, March 23, 2012

Ineed the Right Syntax

Hello,

I need the Right Syntax of this Staement

IF(select count(*) from Department where Department_Id=@.De_Id)=0

begin

insert into Depatment vaule.....etc

esle

update

end

just i have problem with the syntax of first If Statement

Something like this would be a bit more efficient.

Searching stops when the first row is encountered, whereas SELECT count(*) has to search the entire filtered set.

Also, 'IF' does not require an 'END' as in Visual Basic.

Code Snippet

IF EXISTS

( SELECT 1

FROM Department

WHERE Department_ID = @.De_ID

)

INSERT INTO Department ( Columns )

VALUES ( @.Values )

ELSE

UPDATE Department

SET

Column1 = @.Value1,

etc.

|||

For anyone who is currently doing the first touch to the new version of SQL Server 2008, you should try the MERGE statement (aka UPSERT) which was requested for many of the previous version and is finally implemented.

Jens K. Suessmeyer.


http://www.sqlserver2005.de

Monday, March 12, 2012

Indexing

Throughout the course of trying to optimize our database (not really my
position)...the topic of indexing has come up. Our IT department is pretty
feeble and no one (who should know) seems to know what it involves. Are
there any decent resources regarding what it is and how to effectively use
it?
Thanks,
James
check out www.Sql-Server-Performance.com
I recommend load testing before and after all changes to compare all deltas.
If you want more specifics, post back and I'll provide more info...
Greg Jackson
PDX, Oregon
|||www.sql-server-performance.com has various articles that might help you.
I would also recommend picking up Ken England's _Microsoft SQL Server 2000
Performance Optimization and Tuning Handbook_ on Digital Press.
"James Baker" <cppjames@.hotmail.com> wrote in message
news:OyisojnaEHA.2840@.TK2MSFTNGP11.phx.gbl...
> Throughout the course of trying to optimize our database (not really my
> position)...the topic of indexing has come up. Our IT department is
pretty
> feeble and no one (who should know) seems to know what it involves. Are
> there any decent resources regarding what it is and how to effectively use
> it?
> Thanks,
> James
>

Friday, March 9, 2012

Indexing

Throughout the course of trying to optimize our database (not really my
position)...the topic of indexing has come up. Our IT department is pretty
feeble and no one (who should know) seems to know what it involves. Are
there any decent resources regarding what it is and how to effectively use
it?
Thanks,
Jamescheck out www.Sql-Server-Performance.com
I recommend load testing before and after all changes to compare all deltas.
If you want more specifics, post back and I'll provide more info...
Greg Jackson
PDX, Oregon|||www.sql-server-performance.com has various articles that might help you.
I would also recommend picking up Ken England's _Microsoft SQL Server 2000
Performance Optimization and Tuning Handbook_ on Digital Press.
"James Baker" <cppjames@.hotmail.com> wrote in message
news:OyisojnaEHA.2840@.TK2MSFTNGP11.phx.gbl...
> Throughout the course of trying to optimize our database (not really my
> position)...the topic of indexing has come up. Our IT department is
pretty
> feeble and no one (who should know) seems to know what it involves. Are
> there any decent resources regarding what it is and how to effectively use
> it?
> Thanks,
> James
>

Indexing

Throughout the course of trying to optimize our database (not really my
position)...the topic of indexing has come up. Our IT department is pretty
feeble and no one (who should know) seems to know what it involves. Are
there any decent resources regarding what it is and how to effectively use
it?
Thanks,
JamesThis is a huge topic. See SQL Books Online. (BOL) Make
sure to thoroughly understand where they should be put
before you start applying them all over the place. (Its
been known to happen.)
>--Original Message--
>Throughout the course of trying to optimize our database
(not really my
>position)...the topic of indexing has come up. Our IT
department is pretty
>feeble and no one (who should know) seems to know what it
involves. Are
>there any decent resources regarding what it is and how
to effectively use
>it?
>Thanks,
>James
>
>.
>|||check out www.Sql-Server-Performance.com
I recommend load testing before and after all changes to compare all deltas.
If you want more specifics, post back and I'll provide more info...
Greg Jackson
PDX, Oregon|||www.sql-server-performance.com has various articles that might help you.
I would also recommend picking up Ken England's _Microsoft SQL Server 2000
Performance Optimization and Tuning Handbook_ on Digital Press.
"James Baker" <cppjames@.hotmail.com> wrote in message
news:OyisojnaEHA.2840@.TK2MSFTNGP11.phx.gbl...
> Throughout the course of trying to optimize our database (not really my
> position)...the topic of indexing has come up. Our IT department is
pretty
> feeble and no one (who should know) seems to know what it involves. Are
> there any decent resources regarding what it is and how to effectively use
> it?
> Thanks,
> James
>