The Meaning Of Set NoCount On And Off?
Jul 12, 2006Any one help me out ?
Thank you very much .!
Any one help me out ?
Thank you very much .!
Is set nocount on or off by default if you dont type anything for set nocount??cheers!!
View 2 Replies View Relatedwhat does SET NOCOUNT ON do??
View 2 Replies View RelatedIf I understood correctly from some reading SET NOCOUNT ON is use so that my sp does not return the number of row affected and this should improve greatly the performance of my sp. I should use if for all insert, delete adn update sp. Is this correct? Is there any situation I need to have it set to OFF?
What about if I only do a SELECT * FROM Table, is there any point to turn this ON?
Thanks.
I'm trying to write some stored procs. Can somebody help me?
What does "set nocount on" do? And when should I use it?
Thank you,
Anastasia
Hi, i have the next problem...
I work with:
- Sqlserver 2000
- Web server, Tomcat.
- JDBC.
- Java Aplication.
I notice that when I call a store procedure from the aplication java, I usually set no count on in my sp because of some exception errors in my aplication.
But I have one special version of a jdbc that it doesnt work with this parameter. I wish it could be a parameter of the database that is set by the jdbc, but i´m not sure.
Any idea?????
Thanks.
hi
in stored procedures i don't want to display message as
these many rows
eg: (1 row(s) returned)
for that i wrote
SET NOCOUNT ON
but also it displays
is their any ather solution
or else iam going in wrong way
Malathi Rao
i useset nocount on inside the stored procedure at the beginning however theNumber of Rows Counted/Affected shows up when I execute the storedprocedure in query analyzer using execute sprocName. I also tried toadd theSET NOCOUNT ON at the beginning of the procedure and it still shows thenumber of rows affected.if i setset nocount onexec sprocName then the result set does not show the number of rowsaffected.Any idea why this happens? I know that NOCOUNT is set on runtime notparse time.Thanks!
View 3 Replies View RelatedI donot know how to use SQL NOCOUNT . I have written store procs for select and insert , Below are the store procs ,Can anyone tell me how to use SQL NOCOUNT in this StoreProcs???
Select:
if exists (select * from dbo.sysobjects where id = object_id('[dbo].[GetAllLinks]') )drop Procedure [dbo].[GetAllLinks]
GO
CREATE Procedure [dbo].[GetAllLinks]
AS
Select * from UsefulLink
Go
Insert Storeproc:
if exists (select * from dbo.sysobjects where id = object_id('[dbo].[InsertLink]') )drop Procedure [dbo].[InsertLink]
GOCREATE Procedure [dbo].[InsertLink]
@Title varchar(100),
@Location Varchar(100),@ID int OUTPUT
AS
Set @ID = -1Begin Transaction
Insert Into UsefulLink(Title, Location) Values
(@Title,@Location)if @@error <> 0
RollBack Transaction
Else
BEGIN
Commit Transaction
Select @ID = @@identity
END
Go
What I am Trying To Achieve
I am trying to get the ID of the row I am inserting - using code that works fine on: SQL Server 2000 with an ODBC connection and SQL Server 2005 with an ODBC connection
Problem
When the code is executed it inserts the row 4 times.
My Settings
I have the following OLE DB connection string:-
Provider=SQLOLEDB.1;User ID=myuserid;Initial Catalog=dbname;Data Source=dbserveraddress;User Id=myuserid;PASSWORD=mypassword;
and I am executing the following SQL:-
session("sessionID") = dbExecuteRS("SET NOCOUNT ON;INSERT INTO myTable (ipAddress) VALUES('"& request.serverVariables("REMOTE_HOST") &"');SELECT SCOPE_IDENTITY();SET NOCOUNT OFF;")(0)
dbExecuteRS = a function that executes a query
I know my asp page is only executing this sql once but the SQL Profiler says it is running multiple times.
What I've Tried So Far
1) A normal insert works fine - only inserts one row
2) The same SQL with an OLE DB connection string on SQL Server 2000 encounters the same problem - the insert sql with the set nocount on inserts 4 rows
3) I've tried using this bit of SQL/ASP which causes the same problem:-
set tmpRS = dbExecuteRS("SET NOCOUNT ON;INSERT INTO mytable (ipAddress) VALUES('"& request.serverVariables("REMOTE_HOST") &"');SELECT newID = SCOPE_IDENTITY();")
if not tmpRS.eof then
response.write("tmpRS('newID'): " & tmpRS("newID") & "<BR>")
end if
set tmpRS = nothing
Conclusion
From all of my tests I can conclude that this problem ONLY happens when we are connecting to the database via the OLE DB connection string and using an INSERT statement with SET NOCOUNT ON
All ideas/suggestions appreciated, thanks.
I have a SP that has a cursor, and loops. Each loop executes SQL, and inserts values into a temp table on each loop. I want to just have the values in the temp table to show up in QA not the loop's sql results.
I thought:
SET NOCOUNT ON
at the begining of my proc would suppress the results, and then
SET NOCOUNT OFF
prior to my select on my temp table would do this, but the resultset of the loop still shows up in QA. It does suppress the count values on the message tab of QA, but that is it.
I tried something simple like:
SET NOCOUNT ON;
GO
SELECT * FROM [Contact]
And it still show the results in the grid
Any thoughts?
ThanksEric
Hopefully simple question:
How to configure replication so that replication triggers issue a SET NOCOUNT ON?
Also: are there any negative consequences of adding a SET NOCOUNT ON to replication triggers?
I'm not a DBA so my experience with replication is pretty much non-existent. Hopefully, there's a simple configuration option that I can apply when setting up replication for a database. If not, is it going to be feasible for me to write a script that runs over the replication triggers/procs to add this SET statement (any pointers on inbuilt procs that would help here would be real useful)?
Thanks in advance
Christian
In ado.net (using C#). have a statement such as "sqlCommand cmd=new sqlCommand(sqlStatement,stringConnection,sqlTransaction)". do you know the meaning of this bold parameter ? is it its tasks ? thank very much
View 1 Replies View RelatedI was looking at a Miscrosoft example of a SQL "INSERT INTO".
One example they give isINSERT INTO Northwind.dbo.Shippers (CompanyName, Phone)
VALUES (N'Snowflake Shipping',N'(503)555-7233') What does the "N" stand for (or do) in N'Snowflake Shipping'? Is this really needed? I've looked around some and can't find any discussion about it.
Hi,
I cant understand what is the meaning of & ~. I have seen the same in following query. Could any one explain me please.
select p.action & ~convert(int, 0x10000000), N'column' = col_name(p.id, p.colid), p.uid, N'username' = user_name(p.uid),
p.protecttype, o.name, N'owner' = user_name(o.uid), p.id, N'grantor' = user_name(p.grantor)
from #output p, dbo.sysobjects o
where o.id = p.id
order by p.uid, p.id, p.protecttype, p.action
Thanks
-- Krishna
set @pDate2= dbo.AsString(@pYear,@pMonth,@pDay2,23,59,59)
explain the above query
hey, can anybody help me to understad that code:
SELECT companies.Contact_Company AS am_label1,
ISNULL(Incident_CNT,0) AS NumberOfIncidents
FROM (
SELECT DISTINCT Contact_Company FROM HPD_Help_Desk
) companies LEFT OUTER JOIN (
SELECT COUNT(*) AS Incident_CNT, Contact_Company AS am_label1
FROM HPD_Help_Desk
WHERE Status< 5
AND DATEADD ("s", submit_date, '1/1/1970') >= CAST(CONVERT(char(8),GETDATE(),112) AS datetime)
GROUP BY Contact_Company
) IncidentsByCompany
ON companies.Contact_Company = IncidentsByCompany.Contact_Company
Thank you.
Code Snippet<Query>UPDATE OPTIONS SET OptionText = '~DrawerPort~' WHERE...
What is meant by "~" here?
Thanks
In the following example the line of code
IF RIGHT(@StringArray,1) != @Delimiter
includes " != ". What does it mean?
Thanks, Bill
Full Example:-- Creates a UDF that returns a string array as a table result set
CREATE FUNCTION dbo.udf_ParseArray
( @StringArray varchar(max),
@Delimiter char(1) )
RETURNS @StringArrayTable TABLE (Val varchar(50))
AS
BEGIN
DECLARE @Delimiter_position int
IF RIGHT(@StringArray,1) != @Delimiter
SET @StringArray = @StringArray + @Delimiter
WHILE CHARINDEX(@Delimiter, @StringArray) <> 0
BEGIN
SELECT @Delimiter_position =
CHARINDEX(@Delimiter, @StringArray)
INSERT @StringArrayTable
VALUES (left(@StringArray, @Delimiter_position - 1))
SELECT @StringArray = STUFF(@StringArray, 1,
@Delimiter_position, '')
END
RETURN
END
GO
An example for finding the length of a string is:
SELECT LEN (N'She sells seashells by the sea shore')
This returns 37. Without the N, it still returns the same 37. Why is N used?
Thanks.
Bill
Hello All,
Does anyone knows what is the meaning of IDENTITY in following 2 rows.
[UserId] [bigint] IDENTITY (0, 1) NOT NULL ,
AND
[ProductId] [bigint] IDENTITY (1, 1) NOT NULL ,
Thanks in advance
--kneel
Actually, I don't know what is the meaning and difference of "N" in thefunction.Thanks.
View 1 Replies View RelatedDear fellows,
LOP_BEGIN_XACT, LOP_COMMIT_XACT,
LOP_INSERT_ROWS
Labels as the ones are easy recognizable when you explore LDFS by mean DBCC or whatever but on the contrary the following ones are tricky to reach the meaning:
LOP_IDENTITY_TYPE
LOP_DELTA_SYSIND
LOP_SET_BITS
Does anyone have any link related with this? I tried hard to search by Goog or something like that but unsuccessfully at all.
Hi
Is it possible to find records that contain the string "cyber-shot" when the value for search is "cybershot"?? (This is an example and I need a dynamic solution)
Thanks,
Inon.
When we send a message in service broker we send nchar(0xFEFF) in the start of the xml file.
What is the meaning of nchar(0xFEFF)?
Thank you.
Bishoy
Hi,
Does anyone know the meaning of the datacode different values? I understand that 0 is OK and 1 is not, what is the meaning of the rest? I have an execution with no errors except a datacode=3 in the PackageEnd event. What does it mean?
Thanks,
Liran
The documentation says:
"An integer value that identifies the event associated with the log entry. The value 0 indicates the event provided no identifier."
When I look at the sysdtslog90 table and I filter for 'PackageEnd' events, I see a value of 0, 1 or 3 in the datacode column. Is there any information I can glean from these values, e.g. package success or failure?
When you write a sql query, some times there is curly braces within a query in a asp.net application. What is the meaning of that?
select column1, column2, column3
from table1
where column1 = 'somethin'
{LIMITDATE}
order by column3
So what is being used in here {LIMITDATE} and can some one explain this to me? I use C#.
Help
Why is the unsed space is negative number? Whould that affect the database? How do you fix the negative number?
If 'out of lock' happen, how do you check at what level the object was/is locked and how many locks is needed to configure?
Thank you ahead of time
as Christopher Yager say in "Need distributed service broker sample", I also test sending messages between two SQL Server 2005 instances,and after I setup the test environment with instance1 and instance2,I find queue [q2] in ssb2 can't receive message from ssb1. when I query by "select * from sys.transmission_queue",I get some message records that transmission_status is "64(error not found)".
View 12 Replies View RelatedI have some basic skill in SQL Server Management Studio Express already .
But , I still can't understand the exact meaning of ConnectionString.
connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database1.mdf;Integrated Security=True;User Instance=True"
code above is copied from a machine-generated app.config.
Questions are:
1.what do [[ | ]] and [[ ]]mean in AttachDbFilename=|DataDirectory|Database1.mdf ??
2.what does User Instance mean? And if this it false, what will happen in my computer.
3.Some string I saw before contains InitialCatalog= Northwood. What are the differences between initialcatelog and attachdbfilename ?
Very thanks
Dear friends,
I'm reading Wiley's Data mining with SQL Server 2005... There are MANY things I can't understand about MovieClick example (Chapter 3).
I hope someone is going to help me with this troubles...
WARNING (1): I'm a dummy both with sql server and data mining.
WARNING (2): My English is not good at all.
Just two questions for now:
1) When I create the model to predict the number of bedrooms for homeowners, the book says to check BEDROOMS as Predictable... question: is it also an INPUT for the model, or PREDICTABLE only?
2) I'd like to keep this model (number of bedrooms.......) and make a prediction query.
- Query builder
- select case table -> Homeowners
- Drag the Customer ID column from the Homeowners table and drop it on the grid
- Drag the BEDROOMS column from the mining model and drop it on the grid.
- On the last row: Source=PredictionFunction, Field=PredictProbability
- Drag the BEDROOMS column from the mining model and drop it into Criteria/Argument
- Add (i.e.) 'Two or Three' to the field Criteria/Argument
I execute the query and I obtain many rows in a table with the following colums: CustomerID, BEDROOMS and Expression: WHAT DOES THIS MEAN?
WHICH INFO DO I GET FROM THOSE NUMBERS? WHAT CAN I LEARN FROM THEM?
Thanx a lot in advance, please help me!
I wanted to know the meaning of Granlatiy of Fact with some example.
View 3 Replies View Related