Thursday, February 9, 2012

@@ROWCOUNT

Hi all.
Why doesn't this query return number of affected rows?
UPDATE tblOrderPackages
SET packageIsSend = 1
WHERE id = 134
SELECT @.@.ROWCOUNT AS rowsAffected
Thanks,
Sharon.It should. Is this in a stored procedure or something? What do you get as a
result?
MC
"Sharon" <nothing@.null.void> wrote in message
news:u4Op3j9$FHA.1872@.TK2MSFTNGP10.phx.gbl...
> Hi all.
> Why doesn't this query return number of affected rows?
> UPDATE tblOrderPackages
> SET packageIsSend = 1
> WHERE id = 134
> SELECT @.@.ROWCOUNT AS rowsAffected
> Thanks,
> Sharon.
>|||Hi,
Its a simple query, not in a stored procedure.
When trying to get "rowsAffected" from then result set, i get this:
Item cannot be found in the collection
Sharon.
"MC" <marko_culo#@.#yahoo#.#com#> wrote in message
news:uqTzat9$FHA.3568@.TK2MSFTNGP09.phx.gbl...
> It should. Is this in a stored procedure or something? What do you get as
> a result?
>
> MC
>
> "Sharon" <nothing@.null.void> wrote in message
> news:u4Op3j9$FHA.1872@.TK2MSFTNGP10.phx.gbl...
>|||When i run this in the query analyzer, it works.
"Sharon" <nothing@.null.void> wrote in message
news:%23nheAw9$FHA.984@.tk2msftngp13.phx.gbl...
> Hi,
> Its a simple query, not in a stored procedure.
> When trying to get "rowsAffected" from then result set, i get this:
> Item cannot be found in the collection
> Sharon.
> "MC" <marko_culo#@.#yahoo#.#com#> wrote in message
> news:uqTzat9$FHA.3568@.TK2MSFTNGP09.phx.gbl...
>|||How are you reading this? Perhaps this is not an sql problem?
MC
"Sharon" <nothing@.null.void> wrote in message
news:%23nheAw9$FHA.984@.tk2msftngp13.phx.gbl...
> Hi,
> Its a simple query, not in a stored procedure.
> When trying to get "rowsAffected" from then result set, i get this:
> Item cannot be found in the collection
> Sharon.
> "MC" <marko_culo#@.#yahoo#.#com#> wrote in message
> news:uqTzat9$FHA.3568@.TK2MSFTNGP09.phx.gbl...
>|||Hi
Depending on your settings, it might be in the 2nd recordset returned.
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"MC" <marko_culo#@.#yahoo#.#com#> wrote in message
news:O9T4979$FHA.436@.TK2MSFTNGP10.phx.gbl...
> How are you reading this? Perhaps this is not an sql problem?
>
> MC
>
> "Sharon" <nothing@.null.void> wrote in message
> news:%23nheAw9$FHA.984@.tk2msftngp13.phx.gbl...
>|||From asp page:
sql = "UPDATE tblOrderPackages SET packageIsSend = 1 WHERE id = 134 SELECT
@.@.ROWCOUNT AS rowsAffected"
rowsAffected = dbConn.Execute(sql)("rowsAffected")
"MC" <marko_culo#@.#yahoo#.#com#> wrote in message
news:O9T4979$FHA.436@.TK2MSFTNGP10.phx.gbl...
> How are you reading this? Perhaps this is not an sql problem?
>
> MC
>
> "Sharon" <nothing@.null.void> wrote in message
> news:%23nheAw9$FHA.984@.tk2msftngp13.phx.gbl...
>|||Thanks Mike.
This works:
rowsAffected = db.execute(sql).NextRecordset()("rowsAffected")
"Mike Epprecht (SQL MVP)" <mike@.epprecht.net> wrote in message
news:uZn12$9$FHA.1408@.TK2MSFTNGP15.phx.gbl...
> Hi
> Depending on your settings, it might be in the 2nd recordset returned.
> Regards
> --
> Mike Epprecht, Microsoft SQL Server MVP
> Zurich, Switzerland
> IM: mike@.epprecht.net
> MVP Program: http://www.microsoft.com/mvp
> Blog: http://www.msmvps.com/epprecht/
> "MC" <marko_culo#@.#yahoo#.#com#> wrote in message
> news:O9T4979$FHA.436@.TK2MSFTNGP10.phx.gbl...
>|||Sharon wrote on Tue, 13 Dec 2005 14:26:01 +0200:

> From asp page:
> sql = "UPDATE tblOrderPackages SET packageIsSend = 1 WHERE id = 134 SELECT
> @.@.ROWCOUNT AS rowsAffected"
> rowsAffected = dbConn.Execute(sql)("rowsAffected")
Try adding SET NOCOUNT ON at the start - the first recordset returned is
returning the number of rows updated by the UPDATE statement.
Dan

No comments:

Post a Comment