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 2005 Forums
 Transact-SQL (2005)
 Query Help

Author  Topic 

jscot
Posting Yak Master

106 Posts

Posted - 2009-12-31 : 02:55:47

DECLARE @TestVariable varchar(30)
SET @TestVariable = 123
PRINT @TESTVARIABLE

I want to modify my script if a database has been dropped, you will not print a result for that database ID value.Please help me with t-sql code. Thanks in advance.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-31 : 04:22:24
if (object_name(123) is not null)
begin
print 123
end


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-12-31 : 04:23:08
Your question is not clear. What do you want to print?

Madhivanan

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

Sonu619
Posting Yak Master

202 Posts

Posted - 2009-12-31 : 13:07:43
I am trying to modify this script

SELECT DB_NAME( 1 );

**** If database dropped, you will not print a result for that database ID value.
Thanks.
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2009-12-31 : 13:33:22
Scot your if i am not wrong you trying to ask:-

SELECT DB_NAME( 1 );

**** If database dropped, you will not print a result for that database ID value.
Go to Top of Page

jscot
Posting Yak Master

106 Posts

Posted - 2009-12-31 : 13:39:15
I am sorry I didn't clear my question. yes u r right sonu, My question is :-

SELECT DB_NAME( 1 );

**** If database dropped, you will not print a result for that database ID value.
Go to Top of Page
   

- Advertisement -