Strange Problem With SQL Server - Auto-numbers Skipped
Mar 15, 2007
Hi There,
I am having a strange problem with my identity column......
1). I have a table of Products that have an identity column auto-incremented by 1.
2). I have my asp program working quite well in which the Data entry operators are adding the products into my database..... and they do not have any interface through which they can delete products........
3). My Database is running at Web server(MS SQL Server)
My problem is that when i cehcked my database.... there were around 1000 records but the auto increment number have reached to 1500. and when i checked in details then i saw that Auto number column is being skipped certain numbers..... like one entry is 1478 then the next one comes to be 1482..... and 1508 to 1516........ Its happening alot of times and it seems that SQL Server is skipping some numbers............
Since it is Auto-Number so i do not have control over it through my code.... So i think the coding might not be the problem...... I have set Identity seed as well as Identity Increment both to 1.
Is there any thing that you can suggest me to do??
(Thanx)
I am using sybase aSE12.5. I have a table with only one column withdatatype char(2). when i query this table to select all the records, ishould get these records in the ascending order and they should be numbered, i.e, the o/p should look something like thiscolumn_name------ --------1 AB2 AC3 ADand so on.I cannot add an extra column and i need this to be done in a single query.--Message posted via http://www.sqlmonster.com
Hi,Please can you let me know the best solution for creating a primary key which automatically increments by 1 each time a record is added. My current Primary key is of type "Int" which increments by 1 each time, but I would like my primary key to contain "ABC" before the 1. So each time a record is added I would like to see:-ABC000001 ABC000002ABC000003Etc, EtcI am using SQL Server 2000 and creating an ASP.Net application, will I need to write code in a Stored Procedure to do this?Regards,Brett
i would to make a column contains of 3 characters and 6 auto increment numbers (example: "DLL - 123456")
and made it primary key and which data type i should use. i do not know whether i use after insert trigger in two columns one for three characters and another for code which has identity property >>>so please help me
I have a database that has entries that I want sorted by date order. Each entry has an auto ID number allocated (primary key auto sequencing), which I want to change to reflect the sorting (so the first date has the first auto ID number and so on).I've gone into the database and sorted the entries as I want them. Then I've gone into Design View to delete and restablish the primary key autosequence. However, it is not keeping the date order in the database (ie entry ID 3140 date is 12/06/2015, but 3141 is 02/02/2012). How do I get it to maintain the order?
I have a report with a column which contains either a string such as "N/A" or a number such as 12. A user exports the report to Excel. In Excel the numbers are formatted as text.
I already tried to set the value as CDbl which returns error for the cells containing a string.
The requirement is to export the column to Excel with the numbers formatted as numbers and the strings such as "N/A' in the same column as string.
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
One of my application i am using is very slow,(SQL 2005 backend).I am trying to find out the tables and add index to it.But this time my profiler is skipping the records(Trace Skipped Records).Is there any settings?,so that it shows up all the records.
Note: i dont have the code of the application,but i can find few tables holding 2-3 millions of records.I want to know the column name,to create index.
Can someone please help in in understanding what I have done wrong. My company is using Backup Exec 7.3 as it's back up application. I have built a server, installed SQL, Built an database and added logins. I am backing up my database and Transact Log Files to specific folders on my partioned drive. Why when I run the backup ups, It backs up everything EXCEPT for my SQL folders. It seems to Skipp all SQL Folders. Please Help, I need to have this funtion working properly. What have I done wrong or what do I need to do to make this stop. Does this perhaps have something to dwil Here is an example of the backup Message in Backup Exec that I am recieving:
Media Name: "DIFF" Backup of "FEPTESTE$ " Backup set #41 on storage media #1 Backup set description: "Daily 6" Backup Type: DIFFERENTIAL - Changed Files Backup started on 6/28/02 at 12:36:21 AM. The item Microsoft SQL ServerDataMSSQLDataTESTDB_Data.MDF in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamaster.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamastlog.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamodel.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamodellog.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamsdbdata.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatamsdblog.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLDataorthwnd.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLDataorthwnd.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatapubs.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDatapubs_log.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLDataempdb.mdf in use - skipped. The item Microsoft SQL ServerDataMSSQLDataemplog.ldf in use - skipped. The item Microsoft SQL ServerDataMSSQLLOGTEST_Log.LDF in use - skipped.
Backup completed on 6/28/02 at 12:37:11 AM. Backed up 48 files in 24 directories. 14 items were skipped. Processed 23,876,604 bytes in 50 seconds. Throughput rate: 27.3 MB/min
I have a serious issue with transferring binary(8) data from SQL Server 2008 R2 to Excel 2010.
A standard query is made in Excel (Data -> From Other Sources -> From SQL Server) and it works... almost perfect.Almost, because in the query result I have almost all columns in destination spreadsheet, except of those columns which are binary(8) format in my table in SQL Server.
So, in SQL there are columns - let's say:
Date Start time End time User ID (as binary(8) format) Memo (as string) ...
After Excel's query is done, in Excel there are only columns:
Date Start time End time Memo (as string) ...
All columns with types = binary(8) are skipped.
I tried:
1. Export from SQL Server to CSV file and then from CSV file to Excel (all columns as string) and it works, but it has to be automated so CSV is not a good idea.
2. Adding to ConnectionString additional parameters NO_BINARY_RESULT=1 - does not work.
3. Adding to ConnectionString additional parameter IMEX=1 - does not work.
We've set up transactional replication to continue on data consistency errors and we do see in the replication monitor that records are skipped at the subscriber. Our subscriber is SQL2K and our publisher is SQL2K5. How can we see the records that were skipped and why they were skipped.
Why does M$ Query Analyzer display all numbers as positive, no matterwhether they are truly positive or negative ?I am having to cast each column to varchar to find out if there areany negative numbers being hidden from me :(I tried checking Tools/Options/Connections/Use Regional Settings bothon and off, stopping and restarting M$ Query Analyer in betwixt, butno improvement.Am I missing some other option somewhere ?
I tried to load a fixed width flat file with around 300,000 rows. However, only the first 8xxxx rows were loaded to the destineation table and the rest row were loading blank records. There was no error message showing during package execution. I've tried to split the file in half and the result was the same. So it wasn't the data file problem.
Would there be any buffering issue I need to cater for inside the package? Thanks!
I have a table with a column ID of ContentID. The ID in that column is all NULLs. I need a way to change those nulls to a number. It does not matter what type of number it is as long as they are different. Can someone point me somewhere with a piece of T-SQL that I could use to do that. There are over 24000 rows so cursor change will not be very efficient.
I am copying the template with header before loading the data. I tried deleting Dataflow task, Excel Connection manager etc., nothing seems to work and there are no nulls in the data. I did this several times, workaround seems to not working this time.
Since upgrading from SQL Server Management Studio 2008 R2, I've noticed that it no longer autosaves queries that have not been manually saved first. If a file has been manually saved the autorecover files end up in the following directory:
%appdata%MicrosoftSQL Server Management Studio11.0AutoRecoverDatSolution1
However, I have ended up in the situation where I have unsaved queries when my computer has crashed and have not been able to recover them.
I have also found references to .sql files stored in temp files in the following directory, but the files here seem to be very haphazardly caught:
I have an 'ID' column. I'm up to about ID number 40000, but not all are in use, so ID 4354 might not be in any row. I want a list of all numbers which aren't in use. I want to write something like this:
select [numbers from 0 to 40000] where <number> not in (select distinct id from mytable)
I have an MS SQL Server table with a Job Number field I need this field to start at a certain number then auto increment from there. Is there a way to do this programatically or within MSDE?
I am using sql server 2005. I stuck out in a strange problem. I am using view in my stored procedure, when I run the stored procedure some of the rows get skipped out means if select query have to return 10 rows then it is returning 5 rows or any other but not all, also the records displyaing is randomly coming, some time it is displaying reords 12345 next time 5678, other time 2468.
But if I run seperately the querys written in SP then it returns all the rows. Please give me solution why it is happening like this.
There are indexes in the tables.
Once I shrink the database and rebuild the indexes, from then this problem is happening. I have rebuild the indexes several time, also updated the statistics but nothing improving.
I restored a development database to a test database on the same server. I thought this would be a good thing to do because testers would have the same data as developers and the tables would be exactly alike. However, I noticed that the object_id is identical for the tables. For example, the Accounting Calendar in the development database and the Accounting Calendar in the test database have the same Object_id. Could anyone verify that this is or is not going to cause me trouble?
I'm trying to take data from a form and insert it into a SQL database. Everything works fine until I try inserting a number with the comma separator in the number field. The data type in SQL is integer. Are there any special settings to get SQL to accept a comma separated number using ASP?
i m using sql server 2000. My problem is tht no matter what date i enter, sql server always displays it as 1900-1-1. This is happening on all columns which have been specified as datetime. Whts the problem & the solution to the problem?
I get this SQL-sever error in my application. I guess it has something to do with the declaration of namespaces? Does anyone know for sure? Thanks in advance!
The type 'System.Data.Selclient.SqlConnection' exists in both 'c:WINDOWSMicrosoft.NETFrameworkv2.0.50727System.Data.dll' and 'crogramMicrosoft Visual Studio 8Common7IDEPublicAssembliesSystem.Data.SqlClient.dll'
I have a script that creates a database and sets up everything required for merge replication. Merge replication is pull with a single parameterized row filter based on HOST_NAME() and joins on other tables. It works perfectly. I recently decided to drop all my identity columns and use rowguid's instead.
I modified my script by only changing the primary key column definitions, basicaly I went from "[Id] [int] NOT FOR REPLICATION IDENTITY (1,1) NOT NULL PRIMARY KEY CLUSTERED" to "[Id] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY CLUSTERED".
The script still works fine. Everything is executed succesfully and even the snapshot agent finishes it's job.
But the problem is, that when I want to create a partition I get the following error:
A value for the parameter @host_name was specified, but no articles in the publication use HOST_NAME() for parameterized filtering. (.Net SqlClient Data Provider). Microsoft Sql Server, Error: 20672
If I try to synchronize a subscription then the subscription is created succesfully, but I get an error while synchronizing stating: Merge agent was unable to determine if another subscription exists for the current partition.
And yes, I do have my filters set up 100% correctly.
The funny thing is, if I create the publication via Management Studio, then I don't get that error. But if I create the publication via Management Studio, immediately afterwards generate the script for it, delete the publication and create the publication from the generated script, I get the error again
From this I have concluded that no way can the problem be in my new script... Everything is dandy fine with the server as well, because the original scipt still works flawleslly.
Does anyone have any ideas what I could try to get things working? Has anyone even gotten merge replication set up via script, while database -> uses only rowguids, hostname parameterized filter and joins? Or should I just report this as a bug to Microsoft and go back to my original script, including the identity hell?
PS! I'm using Windows Server 2003 Standard x86 SP2, SQL Server 2005 Standard x86 SP2
"tempdb is skipped. You cannot run a query that requires tempdb"?
We're running a .Net web application with a SQL Server 2000 backend, and we get the error intermittently. Restarting the SQL Server service seems to fix it, as it causes tempdb to be rebuilt, but this isn't a long term solution. Any direction or hints would be greatly appreciated. Thanks! - Mike
I am trying to use a condition in a query with CTE but I got an error.It is simple enough but I just cannot get it work. Any help will be greatly appreciated! Msg 156, Level 15, State 1, Line 8Incorrect syntax near the keyword 'if'. declare @i as int set @i=1; with CTE_A as ( select 'B' )
if @i=1 ---this part get problem select * from CTE_A else select 'B'
I have web app and it is workin perfectly when i hawe SqlExpress started even if my database is in SqlServer (is that maybe that i did try membership provider if so how can i remove membership.) so i dont know how to solve this problem without using SqlExpress.. Can some one pleas help me. "1.0"?>
"true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> "true">