Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server crashes when calling function from Execute statement

Status
Not open for further replies.

Dons1000

Programmer
Jul 18, 2006
17
US
Hello, I have a SQL Server 2000 and receive an error message when calling a function within a execute statement. I'm not sure if you can call a function
within an execute statement but I would think I would just receive an error message and it wouldn't crash my server. I had to restart the server for anyone to access it. Below is my query I ran from query analyzer and the error message it produces.

I'm going to rewrite my sql to not use UFYearMonth but would fell better knowing why this happened.

Thanks


exec('update a1 set a1.AmountEntity2 = a2.AdjustedAmount
from #tmpDetail a1 join
(select acType,sum(t1.amount* t3.BalanceSheetFactor) as AdjustedAmount from ledger t1
JOIN ConversionRates t3 ON dbo.UFYearMonth(t1.tdate) = t3.ACPeriod AND t1.CurrencyTypeID = t3.CurrencyTypeID
AND t3.BaseCurrencyTypeID = 1
left join lstAccountCodes t2 on t1.Accode = t2.Accode
' + @sWHERE + ' group by t2.acType) a2 on a1.acType = a2.acType')


Server: Msg 11, Level 16, State 1, Line 0
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]General network error.
Check your network documentation.
Server: Msg 10060, Level 16, State 1, Line 0
[Microsoft][ODBC SQL Server Driver][TCP/IP Sockets]ConnectionOpen
(PreLoginHandshake()).
 
Dons,

Not sure that your error message is anything at all to do with the query. Sounds like your network caused the problem.....

Fee

The question should be [red]Is it worth trying to do?[/red] not [blue] Can it be done?[/blue]
 
I tried calling this function (dbo.UFYearMonth) a week earlier inside a execute command and I had the same issue.

I replaced the function in my sql statement with the the code from the function and it works fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top