Questions tagged [nocount]

Setting NOCOUNT ON / OFF enables or disables the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set.

Setting NOCOUNT ON / OFF enables or disables the message that shows the count of the number of rows affected by a Transact-SQL statement or stored procedure from being returned as part of the result set.

27 questions
1
vote
2 answers

Powershell and SQL Server - set nocount

I am writing a powershell function to retrieve a list of students from our database but the first item returned is always the number of records. I can't figure out a way to incorporate the set nocount on into the the script - any ideas? The function…
1
vote
2 answers

Override rows number affected returned by stored procedure that uses cursor inside

I have a stored procedure simplified to the following code: SET NOCOUNT ON DECLARE @count INT DECLARE @temp TABLE INSERT INTO @temp SELECT @count = count(*) FROM @temp DECLARE [cursor] FOR SELECT id FROM @temp OPEN [cursor] FETCH NEXT FROM…
abatishchev
  • 98,240
  • 88
  • 296
  • 433
0
votes
1 answer

Calling INSERT statements in MS SQL (Azure) from Python results in errors, NO COUNT ON does not work

I am a newbie so please bear with me. I am trying to do a very simple insert from Python into a MS SQL database. I have tried pure pyodbc resulting in "pyodbc.ProgrammingError: No results. Previous SQL was not a query.": import pyodbc server =…
0
votes
0 answers

Trigger returned a resultset and/or was running with SET NOCOUNT OFF - not sure what's causing this

I'm running into an intermittent error with a SQL Server trigger that has me stumped, because it seems like I'm doing all of the right things to prevent the error from occurring. The error I'm getting is "A trigger returned a resultset and/or was…
0
votes
1 answer

How to SET NOCOUNT ON in a vb.net

Setting "SET NOCOUNT ON" in an application always benefits the performance of the application. But how i can set it in my vb.net application in a VB.net project? Here are my code Dim myConn As OleDbConnection Dim myAdapter As OleDbDataAdapter Dim…
0
votes
1 answer

C# SqlCommand.ExecuteNonQuery() and SQL SET NOCOUNT ON

I have searched all afternoon and don't believe this is a duplicate to the other questions floating around like ExecuteNonQuery() and SET NOCOUNT ON. I have also found an interesting blog about Finding code smells using SQL Prompt: the SET NOCOUNT…
Storm
  • 1,848
  • 4
  • 20
  • 39
0
votes
3 answers

What is the worst that could happen if I don't use SET NOCOUNT ON in a stored procedure in T-SQL?

MSDN states SET NOCOUNT ON prevents the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. For stored procedures that contain several statements that do not return much actual data, or for procedures…
PBeezy
  • 1,222
  • 2
  • 17
  • 26
0
votes
1 answer

Query Result export per email

I Try to export the Query result per E-Mail as Attach here the code: DECLARE @Delimiter Char(1) SET @Delimiter = CHAR(9) EXEC msdb.dbo.sp_send_dbmail @profile_name = 'MyProfile', @recipients = 'myemailaad@mail.com', @subject = 'Defects Total…
Qsec
  • 11
  • 4
0
votes
2 answers

Trigger with NOCOUNT outputs 1 or more row(s) affected when no datatable rows were changed

I am using SQL Server 2012. I have triggers on a view, with the intent of allowing my users to perform DML actions on it like any other table. These triggers have SET NOCOUNT ON and have many IF...RAISERROR(...) RETURN statements to catch logical…
zambonee
  • 1,599
  • 11
  • 17
0
votes
1 answer

Why does SET NOCOUNT ON fix an embedded query in excel

I am newer to SQL and found an answer to my problem, but being new to this site it won't allow me to comment on it to get clarity about how it worked. I tried to embed a SQL query in excel and it wouldn't work until I SET NOCOUNT ON before my…
0
votes
1 answer

How to Call SQL NOCOUNT outside from a Java application

Prior to installation our application checks SQL to make sure it has correct permissions along with various settings. One of those settings is @@OPTION NOCOUNT. I cannot seem to figure out for the life of me how to pull this value from the db. I've…
user1158745
  • 2,402
  • 9
  • 41
  • 60
0
votes
1 answer

Suppress result from insert trigger

A MS SQL insert trigger causes some grief as it returns a result. Is there a way to disable any result from being sent? I've used 'set nocount on', but that doesn't seem to do much... create trigger tr_insert_raw_data on raw_data instead of…
Max
  • 101
  • 8
1
2