If you run your queries or SPs in an SQL Query Analyzer (which you can launch via the Enterprise Manager), you'll see there are 2 result windows. One called "Grids" returns recordsets, the other called "Messages" returns plain text print output. The "SET NOCOUNT ON" command tells SQL Server to not spit back "(X rows affected)" every time it runs a query. This print output does not normally affect your CF scripts, since they only really care about the recordsets, which are found in the Grids window. However, if there is an error, then CF looks to the print output in the Messages window to get the error message, which it returns to CF's script so it can print a reasonable error message. Sometimes, if you have lots of "(X rows affected)" cluttering up your query or SP's Message output, then CF cannot find nor return a good error to you: you'd get as an error that "(x rows affected) (y rows affected) ... (z rows affected)" up to however many characters the error can handle. The actual error occurs later, and gets cut off.
So, it is best to use the SET NOCOUNT ON command, just to keep your output clean. If you're debugging, you can remark it out, but put it back for production. Also, I think if you use Scope_Identity() instead of @@identity, you're safer, since it returns the identity within your scope. This is not affected by other users, not affected by triggers, etc. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2263 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
