Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 if command

Author  Topic 

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-01-08 : 10:26:53
ALTER PROCEDURE sp_Kullanici_KullaniciBilgiGetir
@KullaniciAdi varchar(50),
@Durum char(1)
AS
if @Durum = 1
begin
Select ID from Oyuncular where KullaniciAdi = @KullaniciAdi
end
If @Durum = 2
begin
Select * from Oyuncular
end
RETURN



if @durum=2 it needs kullaniciAdi too but i want that if durum = 2 then select * from Oyuncular without requireing KullaniciAdi
how to do it ?
in both if it needs kullaniciAdi but i want it to need KullaniciAdi at first


MS BLESS US

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-01-08 : 10:40:40
ok i solved i think.
When i send KullaniciAdi as blank
it gives me what i want.
thx

MS BLESS US
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-01-08 : 11:57:14
quote:
Originally posted by bilencekic
ALTER PROCEDURE sp_Kullanici_KullaniciBilgiGetir...

That is so cool. I am going to name my next stored procedure sp_Kullanici_KullaniciBilgiGetir just for the hell of it.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-01-08 : 11:59:32
you're even geekier than i thought, bruce.

[edit]
bilencekic, don't prefix your stored procedures with sp_
spProc is ok sp_proc isn't.
if a sproc has a sp_ prefix the sql server first goes to the master db to look for it. so if by any chance you'd have
sp_Kullanici_KullaniciBilgiGetir in your masterdb that one would get executed and not the one in your db.

Bruce i agree though, it's a cool sproc name
[/edit]


Go with the flow & have fun! Else fight the flow
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2006-01-08 : 13:01:33
But surely the letter i in Kullanici should be dotless?
...which reminds me...
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-01-08 : 16:01:42
lol you mean it work slower by going to master?
it works but
i use sp_ with my all projects

MS BLESS US
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-01-08 : 16:11:30
I didint get what you say ?
My master db has same procs
and my proc named with sp_ appears in my db
no performance or other problem :D so what is the problem ? can u pls expalaiN?

MS BLESS US
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-01-08 : 19:21:33
The sproc will work if prefixe with sp_, but the server will first check to see if a sproc by that name exists in Master before looking in the current database. That slows things down.
In general, though this is a hotly debated subject, the use of prefixes to describe objects is considered old-fashioned and is discuraged. This include sp_, tbl_, vw_, whatever. In principle that physical manifestation of objects should be separate from their logical purpose. The problem can become particularly evident with tables and views. Say you name your tables with tbl_ and then decide to modify your table, but to prevent breaking existing code you create a view based upon your new table to manifest data in the old format. Now you end up with a view prefixed by tbl_. Or you have a view that you decide to turn into a pre-aggregated table. Are you going to leave the new table's name prefixed with vw_?
Go to Top of Page

bilencekic
Posting Yak Master

121 Posts

Posted - 2006-01-08 : 20:16:55
ok comrade :D i get it.


MS BLESS US
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-09 : 03:20:08
Also refer this
http://vyaskn.tripod.com/object_naming.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -