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.
| Author |
Topic |
|
tocroi72
Yak Posting Veteran
89 Posts |
Posted - 2006-04-19 : 09:13:53
|
| Hello all,Can someone please tell me what is wrong with the below function, i get an error from itCREATE FUNCTION f_PingServer (@servername varchar(50))RETURN integerASBEGIN DECLARE @strCmd VARCHAR(100) DECLARE @result integer SELECT @strCmd = 'ping ' + @servername Execute @result = Master..xp_cmdShell @strCmd , no_output If @result = 0 return 0 else return 1ENDbelow are error messageServer: Msg 156, Level 15, State 1, Procedure f_PingServer, Line 2Incorrect syntax near the keyword 'RETURN'.Server: Msg 178, Level 15, State 1, Procedure f_PingServer, Line 12A RETURN statement with a return value cannot be used in this context.Server: Msg 178, Level 15, State 1, Procedure f_PingServer, Line 14A RETURN statement with a return value cannot be used in this context.Thanks. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-19 : 09:29:52
|
TryCREATE FUNCTION f_PingServer (@servername varchar(50))RETURNs integerASBEGINDECLARE @strCmd VARCHAR(100)DECLARE @result integerSELECT @strCmd = 'ping -n 1 ' + @servernameExecute @result = Master..xp_cmdShell @strCmd , no_outputreturn (@result)end MadhivananFailing to plan is Planning to fail |
 |
|
|
tocroi72
Yak Posting Veteran
89 Posts |
Posted - 2006-04-19 : 09:34:42
|
| thank you !!! i did try return @result but it didn't work , then i tried what i posted - didn't work either - forgot about the () ...Thank you so much. |
 |
|
|
tocroi72
Yak Posting Veteran
89 Posts |
Posted - 2006-04-19 : 09:38:01
|
| i forgot to ask you , what ping -n 1 does? Please execuse me for lacking SQL knowlegeThanks |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-04-19 : 21:06:56
|
| it's not sql, it's a dos command,open a command prompt and type ping/?, this will show you the parameters...--------------------keeping it simple... |
 |
|
|
|
|
|
|
|