Id (indentity) Is Increments On Faults.
Jul 20, 2005Hi,
When i eg. manually ad entries to a table and, cancels the insert Ms SQL
increment the counter on the ID anyway. Is there a way to avoid this
behavior?
Regards
Anders
Hi,
When i eg. manually ad entries to a table and, cancels the insert Ms SQL
increment the counter on the ID anyway. Is there a way to avoid this
behavior?
Regards
Anders
I have a table that consists of an invoice number, the ordering user's customer number, and current shipping status of the invoice.
What I would like is for the invoice number to auto increment whenever I insert into the table. I'm using SQL Server, but I can't find something to check (or whatever) in Enterprise Manager.
I'm certain it's possible, I just have no idea how. Please help!
Cheers,
RobJ.
Hello
I am trying to pull data from a table. I would like to group this dataset by a datetime field.
The result I want is for the records to be grouped together by their create time ( in this case using half hour increments.) All records created from the first half hour get grouped together, all records from the second half hour get grouped together etc. This dataset will contain data from a 24 hour time period (48 groups of data). What is the best way to accomplish? Do I need to use a cursor to accomplish?
Thanks
I am running an application on one NT Server, running against SQL Server 6.5 sp 3, and SQL 7 with sp1 applied.
The application is a 'data migration' type application - ie heavy insert and update workload - against many (50+ tables) with many different SQL statements.
The SQL 7 server is configured with 'floating' memory.
On SQL 7 - I am experiencing very high page faults/second for the sqlservr process - sometimes peaking at over 1,000. I was under the impression any number greater than 10 indicates a problem with system performance.
The same application, same data, same NT configuration etc against SQL 6.5 does not page fault. SQL Server 6.5 completes the work faster than 7.
Could anyone help me understand what's going on ?
Thanks in advance.
My question is, My perfmon counters reads anywhere between 0 and 1200 with the average being around 250 faults/second.
My concern is my memory max size being too large, I have 4gb ram, SQL reports usage at 2.9 GB, my max mem size is 3.9 gb, should I maybe set my SQL server to use a fixed memory size of 2.9 gb?
Thanks in advance
Pete Karhatsu
Copied from SWYNKs' article:
Process: Page Faults/sec
If this value is greater then 0 then the SQL Server process is producing soft page faults and as a result CPU overhead. Try setting the working set size value to be as close to the SQL Server's memory allocation.
I would like to create a field that increments automatically by 1 - to use it as an identifier for a row. This is so dammed simple but I can not find how to do it !
Thank you very much for any help.
By the way I configure SQLExpress with VS2005 and SQL Express Manager.
Thank you very much,
Regards,
Fabian
my favorit hoster is ASPnix : www.aspnix.com !
Hi, all.We have a couple of pathological sql servers that have lots and lots ofpage faults per second, up to 4000. Our client programs are written inC#/.NET 1.1 and utilizes connection pooling.Some of the client programs seems to log in hundred of times persecond, as reported by perfmon->.SQLServer:GeneralStatistics->Logins/sec. Stopping the client programs reduces thatnumber significantly.We've done code reviews of the client programs and they look OK.Monitoring .NET connections&pools does not show anything suspicicous.We're currently rewriting the clients to use one db connection insteadof the pools, but that takes some time and may introduce bugs. Doesanyone know why we have these problems and/or why logins/sec is sohigh? I'm thinking "bugs in the .NET client", but really have noidea...One thought I had was that the Page Faults reported for sqlsrv.exe isrelated to memory mapped IO and therefore can be ignored. Right orwrong?Any thoughs/pointers/ideas, even wild guesses, are most welcome.BjørnPS: The server memory is fixed at 1.5GB out of 2GB physical ram,clients run on the same machine and use TCP/IP comm.(I know...) Thehost itself is not paging.
View 4 Replies View RelatedHi all. Dorky question , but I am still relatively new to the world ofms database servers so bare with me. I am monitoring the page faultrate on a server and it runs at 100% almost all of the time. Cansomeone help me understand what that means?
View 1 Replies View RelatedHello all,
I have the following very simple SQL Query:
SELECT TOP (100) AutoNumber, Date, ZNT, SAT, RAT, RH
FROM HV_Values
ORDER BY Date ASC
This shows the top 100 entries for a table (where there is a date entry every 5 minutes). Here's five sample records:
1 12/4/2006 4:12:11 PM 67.13 70.50 71.56 8.23
2 12/4/2006 4:17:11 PM 67.13 70.50 71.56 8.33
3 12/4/2006 4:22:11 PM 67.19 70.69 71.69 8.19
4 12/4/2006 4:27:11 PM 67.19 70.63 71.69 8.18
5 12/4/2006 4:32:11 PM 67.19 70.69 71.75 8.05
What I'd like to do with the sample query above is take an AVG for one hour for the values ZNT, SAT, RAT, RH...like I stated the records are every five minutes in the table, I'd like to create 60 minute AVGs.
Any ideas or sample queries I can work with?
Thank you very much! gad1
I have an issue with a stored procedure activation on a service broker queue. The activation stored procedure simply RECEIVES the top message and then INSERTs a row into a table with an identity INT column. Each row inserted has the identity column value incremented by 2 rather than 1. Only one row is inserted in the table.
If the activation is set to OFF and then manually calling the original stored procedure the insert works fine and the identity column value is only incremented by one.
Do you have any suggestions on why the identity column value increments by 2?
Thanks.
We are running SQL Server 2000 Enterprise Edition on a 2-node cluster with IIS/ASP.NET front-end hosting 150-200 active connections. There is a SVCHOST process running under LOCAL SERVICE account - hosting the Remote Registry process that is using only 4,200K but is page faulting 200-500 times per second. I realize this process is used for failover, but the page fault seems excessive. Any thoughts on this?
The servers are running Windows Server 2003 with 4 processors and 4gb RAM.
Arkadiy writes "Why @@indentity returns NULL after inserting new row?"
View 6 Replies View RelatedHi folks!
I need to populate a table having an identity field with data (basically I want to make a copy of a table with identity column on another server). When I use BCP to insert data then the values in the identity field is not the same as in the data file but gets incremented from the original.
eg. if the records in the flat file are-
1, 'test1'
2, 'test2'
Now if i insert this into the table (say the last identity value was 100) then rows get inserted as-
101, 'test1'
102, 'test2'
Is there any way by which I can retain the values of the identity column to be same as in the file?
Thanks!
when I use the code
SET IDENTITY_INSERT tss_Cable ON
go
DECLARE @@nextidentval int
SELECT @@nextidentval = MIN(IDENTITYCOL) + IDENT_INCR(tss_Cable)
FROM tss_Cable t1
WHERE IDENTITYCOL BETWEEN IDENT_SEED(tss_Cable) AND 2147483646
AND NOT EXISTS (SELECT * FROM tss_Cable t2
WHERE t2.IDENTITYCOL = t1.IDENTITYCOL IDENT_INCR(tss_Cable))
go
SET IDENTITY_INSERT tss_Cable OFF
I get the following error.
error line 2 Incorrect syntax near IDENT_INCR.
error line 6 incorrent syntax near IDENT_INCR.
I would like to reset the identity without droping the table. I'm using
sql 6.5. I looked at Mark Lessard 12/17/99 respose on this issue and changed
the code to match his version but the same error occured.
How do reset identity seed on table, for example I have table that has gap in the identity such as (1,2,3,5,6, etc..) and I want reset the entire table.
Thank You,
John
What is the best way to do Indentity(1,1) on fields which is varchar(8)?
View 1 Replies View RelatedI'm doing a data transfer from Access to SQL Server, I wish to keep theidentity column (autonumber) values as all the data is already related. Itried the first table append query including the identity column, it worked.Was this fluke? Will it always work? I was under the impression that I wouldhave to issue a "set identity_insert on" before doing this. The SQL databasewill have absolutely no data before the transfer routines are run.
View 15 Replies View RelatedIDE: Visual Studio 2008
DB: SSCE 3.5
OS: WinXP SP2 (CHS)
.....
Code Snippet
String str_sql_insert = "INSERT INTO Person (Name, ShortName, Description, Tag) VALUES ('" + this.TextBox.Text.Trim() + "', '" + this.ShortNameTextBox.Text.Trim() + "', '" + this.DescriptionTextBox.Text.Trim() + "','" + this.TagComboBox.SelectedValue.ToString().Trim() + "); SELECT @@INDENTITY";
SqlCeConnection tempConn = dbman.getConn();
SqlCeCommand tempComm = new SqlCeCommand(str_sql_insert, tempConn);
tempConn.Open();
Object ob = tempComm.ExecuteScalar();
.....
When I run the application there is a error report on the last line of the code above:
[ Token line number = 1,Token line offset = 127,Token in error = SELECT ]
When I copy the SQL string into the QueryBuilder in the VS2008 it is works and returned a correct value.
I want to know is there something wrong with the sql string or the ExecuteScalar() cant execute 2 steps command?
thanks
As an example I have three tables
Table1
ChildName (nvarchar)30
ChildID (INT) Set as €˜IDENTITY€™
Table2
ParentName(nvarchar)30
ParentID (INT) Set as €˜IDENTITY€™
Table3
ChildID (INT)
ParentID (INT)
I have the following code.
Dim dbcnn As SqlClient.SqlConnection = New SqlClient.SqlConnection(dbsettings.getDatabaseString)
Dim dbcmd As SqlClient.SqlCommand
dbcmd_AddDriverRoute = New SqlClient.SqlCommand("usp_Insert", dbcnn)
dbcmd.CommandType = CommandType.StoredProcedure
dbcmd.Parameters.AddWithValue("@ChildID ", cmb_child.SelectedItem)
dbcmd.Parameters.AddWithValue("@ParentID ", "@@IDENTITY")
dbcnn.Open()
dbcmd.ExecuteScalar()
dbcnn.Close()
basically what I want to do is when a child is added I want to be able to insert ParentID (INT) Set as €˜IDENTITY€™ value into table3 ParentID (INT) .
I have my sql statement in place I am not sure how to take an identity value stored in the db.
i have table with one column
CREATE TABLE [dbo].[tblTest](
[ID] [int] IDENTITY(1,1) NOT NULL
how do i insert values.(i,e identity)
I would like to reset the Identity column in a table so it starts at the begining. I am planning to clean out this table.
Thanks
Gary
I'm trying something new, and have hit a snag.
basically, I'm attempting to use two INSERT commands in a single SP. I want to use the PK from the new entry and apply that to the second.
here's the code;
:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::
CREATE PROCEDURE spInsertNewUser
@fn varchar(50),
@ln varchar(50),
@add varchar(50),
@add2 varchar(50),
@ct varchar(50),
@cty varchar(50),
@st varchar(4),
@pc varchar(50),
@ph varchar(50),
@cp varchar(50),
@fx varchar(50),
@em varchar(50),
@pw varchar(50),
@uid varchar(50),
@rc bit,
--@indentity int OUTPUT,
@cid int
AS
SET NOCOUNT ON
INSERT INTO tblUserInfo
(
firstName,
lastName,
address,
address2,
city,
county,
state,
postalCode,
phone,
cellPhone,
fax,
email,
pword,
userUID,
regConfirmed
)
VALUES (
@fn,
@ln,
@add,
@add2,
@ct,
@cty,
@st,
@pc,
@ph,
@cp,
@fx,
@em,
@pw,
@uid,
@rc
)
SELECT @@IDENTITY FROM tblUserInfo
--SET @indentity = @@IDENTITY
INSERT INTO tblUserToCountySubscribedLKP (
UserID, CountyID
) VALUES(
@@indentity, @cid
)
:::::::::::::::::::::::::::::::::::::::::::::::::: :::::::::::::::
I'm sure the problem is largely due to the fact that I am close to completely clueless on such things, but a bit of timely advice from the sage sql wizards here would be most welcome and greatly appreciated.
Hello folks,
I am using the following INSERT statement to add a new record in my table. I want to be able to get the Autonumber UserID field of the newly created record but I am getting the following error: "Characters found after end of SQL statement"
Code:
INSERT
INTO tblUser
(LoginName, UserPassword, EmailAddress, City)
Values
(@User, @UsrPassword, @EmailAddress, @City);
SELECT @@IDENTITY As 'Identity'
What is wrong in my statement?
How do I retrieve the Autonumber field of the newly created record?
How do I handle if the LoginName and/or EmailAddress already exists?
I want to be able save this INSERT statement as an Access Query and call it from my C# code.
I would appreciate any help.
Thanks
Mike
Hi Guys,
I'm using SQL server 2000.
How do I alter column/field from type int (with Identity = Yes Not For Replication) to just normail int field. No more identity. I want it to be done using SQL script( sql query analyzer).
Please help me on this, thx
Regards,
Shaffiq
I imported a table using DTS.
I run SQL statements in my original server database. It works well.
But when I run the same instructions within a stored procedure in my new workstation where I improrted the table I get this error:
Server: Msg 515, Level 16, State 2, Procedure InsertFichierPrix, Line 11
Cannot insert the value NULL into column 'Id', table 'myDBLive.dbo.FichierPrix'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Here is the SQL statements that I run on the original Database:
insert into fichierprix(nomfichier, version, descriptionfr, typeclient,....) values(@NomFichier,'Actuelle', @NomFourFr, 'MembreAcheteur', ....)
And here is my SP that I run on the new imported database:
CREATE PROCEDURE InsertFichierPrix @NomFichier varchar(50), @NomFr varchar(50),@NomAn varchar(50)
AS
declare @NomFourFr varchar(50)
declare @NomFourAn varchar(50)
SET @NomFourFr='liste fournisseur ' + @NomFr
set @NomFourAn='liste fournisseur ' + @NomAn
insert into fichierprix(nomfichier, version, descriptionfr, typeclient,...) values(@NomFichier,'Actuelle', @NomFourFr, 'MembreAcheteur'...)
GO
And here is the execution of my Stored proc on the destination database:
execute insertfichierprix @NomFichier='myfilename2', @NomFr='fournifr1',@NomAn='Fourniang1'
Thank you for helping me.
Hi AllI have a table in SQL Server with ID having indentity inrement by one.Table has not any trigger. Frequently ID in the table jumps.Any help !!!Thanks
View 2 Replies View RelatedI am trying to remove the Indentity property from a column so I can do some clean up. Then will need to add it back. Adding Indentity property back is not a problem, but cant figure out how to remove it in the first place.
Any help would be greatly apprecaited.
Thanks
Dave
Hello, everyone:
I have a table with an indentity column as first column. At beginning it is continue such as 0-50. I delete last 20 columns by hand. The 0-31 is left. When the new data is inserted, I hope the new indentity column begin from 32. How to do that? Now the indentity column begin from 51 as the new data is inserted.
Thanks a lot
ZYT
Hi There
Can anyone tell me how an identity column decides what number to give which row.
I always thought that it was in order of the clustered index.
But i have found the following:
If you have Table A with a clustered index(not unique) say on the first 3 columns.
If the table is empty and you add an identity column, then afterward load it with data the value of the identity column seems to match the clustered index.
But if the table has no identity column and it is filled with data, and then you add an identity column the number for the identity column seems to be all over the place.
So basically how does a newly added identity column know what number to give each row, what if the clustered index is not unique? Is it random ?
Thanx
Dear Friends,
I need a SQL Query to add a identity coloumn for anExisting table. (ie) when i try to alter the table i want to add an identity coloumn.
Thanks in advance.