Transact SQL :: Data Type Auto Identity Is (1,1) But Its Increasing 1000 Each Time

Apr 21, 2015

In my database table has auto Identity file which is (1,1) But Its Increasing 1000 Some time 100 I don't Understand why It is happening in my every table.

View 4 Replies


ADVERTISEMENT

Transact SQL :: Primary Key Auto Incrementing By 1000 Instead Of 1

Jul 13, 2012

We have upgraded our SQL 2008 server to 2012 last month.  i've noted since then that many tables that have auto increment primary key bigint field increases by 1 like it should, then for some reason it jumps up by 1000 or even 10000?  i have seed adn auto increment set to 1 but doesnt effect it.  Is there anything that could be causing the next value to jump that much?

View 18 Replies View Related

Transact SQL :: Select 1000 Rows At A Time From / Into A Large Temp Table?

May 12, 2015

I am using SQL SERVER 2008R2, not Denali, so I cannot use OFFSET FETCH Clause.

In my stored procedure, I am doing a SELECT INTO #tblTemp FROM... Working fine. This resultset is going to be used in an SSIS package which will generate a pipe-delimited .txt file... Working fine.

For recoverability sake, I am trying to throttle back on the commit chunks to 1000 rows per commit until there are no more rows. I am trying to avoid large rollbacks.

Q: Am I supposed to handle the transactions (begin/commit/rollback/end trans) when the records are being inserted into the temp table? Or when they are being selected form the temp table?

Q: Or can I handle this in my SSIS package for a flat file destination? I don't see option for a flat file destination like I do for an OLE DB Destination (like Rows per batch, Maximum insert commit size).

View 6 Replies View Related

Auto Identity For Each Type

Jan 9, 2007

Hello,

I am working on an accounting system using VB.NET and sql server 2005 as a database. the application should be used by multiple users.
i have a the following structure:
Voucher: ID (primary), Date,TypeID, ReferenceCode, .....
Type: ID, Code, Name. (the user can add new type anytime!)
(Ex: PV- payment voucher, JV - Journal Voucher ,....)

When adding a voucher the user will choose a type, according to this type (for each year) a counter will be increminted.
for example: PV1, PV2....PV233,... the other type will have its separate counter JV1, JV2 ,...JV4569,..
I am using the sqlTransaction cause i am doing other operations that should be transactional with the insertion of the Voucher.

The question is :
What is the best solution to generate a counter for each type?(With code sample)

Thanks.

View 4 Replies View Related

Date: Auto Data Type

May 29, 2006

I am really new to this. Is there a way to set up a data type in SQL Server to automatically write the current date to a column? Instead of sending it from the page, the DB just writes the date to the column ...

Any guidance would be great!

-L

View 1 Replies View Related

Auto Increment Auto Non-identity Field

Jan 23, 2004

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?

Thanks, Justin.

View 3 Replies View Related

SQL 2012 :: Seed Value Of Identity Columns Jumps / Gaps By 1000 After Restarting It?

Jan 9, 2015

We just switched from Sql server 2008R2 to Sql server 2012.I am facing one problem with identity Columns "When ever i restarts my sql server,the seed value for each identity column is increased by 1000 (For int identity column it is 1000 and for big int it is 10000).

"For Example if seed value of any table was 3 then after restarting sql server will be 1003 if i again restart sql server it will be 2003 and so on."

After searching on google i found that it is a new feature (don't know what is use of it) in sql server 2012 and having only two solution if you want old identity concept

1. Use sequence object -

a) I am using same database in sql server 2008 and 2012 both so can't use sequence in 2008.

b) if i go with sequence then need not change save procedure for each table,which is bulky task for us.

2. Use Trace Flag 272 (-T272)

I can go with this solution because there is need not do any changes in my application.Some one suggested me that add -T272 in startup parameter,after this sql server identity column will work normal as previous version.I did the same but it is not working.

I don't want to do any changes in my database structure.

how to use this -T272 or why it is not working.

I don't want to use this new identity feature how to suppress it. Why -T272 is not working.

View 4 Replies View Related

SQL 2012 :: Adding T272 Trace Did Not Correct Identity Column 1000 Jump

Jun 15, 2015

After SQL server service restart, a column which is set to auto increment jumped 1000. To fix the issue, I had to add T272 trace flag to SQL startup parameters. However, I did not see the column being reseeded after the service restart, it is still showing the 1000 jump. Am I doing something wrong?

Below the log showing the flag being added to the error log:

LogDateProcessorInfoErrorMSG
2015-06-15 22:29:53.850ServerRegistry startup parameters:
-d E:DATAmaster.mdf
-e E:logERRORLOG
-l E:DATAmastlog.ldf
-T 272

View 3 Replies View Related

Increasing Response Time

May 26, 2008

Hello,

I am currently migrating a DB from Oracle to SQL Server (Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86))

I've used ssma to do the migration, and I'm reviewing the prodedures to check them. I have find a performance problem in one of them, which worked perfectly under Oracle, and I have tried lots of things with no luck, so I guess I need some help

I insert a row in a table, and the time it takes for this is fine, but seconds later I need to read the row, and this Select lasts 1-2 ms more every time. This process is repeated lots of times.

Every insert-select takes 200 ms when it receives the first data (including some other operations that are not increasing the response time), and 200 insertions later it takes about 500 ms, which is really too much, considering it keeps increasing.

The table has 25+ columns, and some of them contain varchar of 3000+ characters.

I make the select using 4 columns in the where part. One of them is a numeric, and the rest are varchar (no one is the primary key).

I've got a clustered index for the primary key, and two more non-clustered indexes. One of them refers to the columns I use in the Select, and the parameters are Fill Factor: 90, and Recompute Statistics Automatically.

I hope I explained properly...

Any ideas?

View 8 Replies View Related

Identity – Yes And Yes (not For Replication) Data Type

Sep 1, 2004

Hi All,
I am new to MSSQL Server 2000. I am sorry if you think that this is silly question.

What is the difference between identity – yes and yes(not for replication)

What are two different situations where I should use identity – yes or identity - yes(not for replication)

Thanks in advance
rainbow11

View 3 Replies View Related

Transact SQL :: How To Change Auto-sequence Numbers To Match Sorted Data

Jun 15, 2015

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?

View 3 Replies View Related

Transact SQL :: Query To Insert Over 1000,0000 Record

May 8, 2015

How to write a query that can insert over 1000,0000 dummy records in the fastest way? My current query is

  DECLARE @d DateTIme = GETDATE()
  DECLARE @c INT = 1
WHILE @c <= 5 BEGIN
INSERT INTO MyTable VALUES (NEWID(),'PREFIX' + RIGHT('0000000000'+ (CAST(@c AS VARCHAR)), 10), DATEADD(MINUTE,@c,@d), FLOOR(RAND()*3), FLOOR(RAND()*2), 'INFO')
    SET @c = @c + 1
END

View 7 Replies View Related

Transact SQL :: Sending Auto Email With Queried Data (On INSERT And On Month Ends)

Oct 22, 2015

I have to send updated Employee list from employee master table to a particular email ID on every last date of Month and when a new employee is added / deleted / edited. Also need to send this as an Excel file 

I tried the following but "Invalid Object name dbo.tbl_EmployeeMaster" error coming while inserting a new employee.

USE [eXact]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[trg_Email]

[Code] ....

View 8 Replies View Related

Table Set Of Records - Show Purchase Time When It Crossed 1000

Feb 10, 2014

I have a table set of records. Its contains some customerID,SportsGoods,Price in different datetime. I want to add customer spent. If crossed 1000 means i have to show purchase time when it is crossed 1000. I need query without while and looping.

Example:

Customer NameGoodsPriceDatePurchased
ABat2501/31/2014
ABall221/31/2014
BCarrom Board4752/2/2014
CTennis Ball502/1/2014
AFootball1502/2/2014
DBat2501/31/2014
BBall221/31/2014
AHockey Bat1252/4/2014
CChess552/4/2014
AVolley Ball552/4/2014

View 9 Replies View Related

Identity Columns Fails To Increment After 2147483585 - Numeric Data Type

Nov 20, 2007

I had a strange problem today with one of the identity fields in a frequently used table. It appears that the Identity column for a table had stopped incrementing after it reached 2147483585. Since I had inherited this table, I am not sure if the identity column type has been modified from int to numeric, but the current type is Numeric (9) which is 19 precision and 0 scale value.

When resetting the seed to 1, it started working. I tried creating a temp table with numeric value and it increments well beyond billions with no problems.


Has anyone encountered this? Any best practices around defining Identity data type (ie. use int or bigint and avoide Numeric)?
Thanks
NS

View 4 Replies View Related

Time Based Data Type

Aug 4, 2005

Right now i'm developing a time attendance system.
So in that case i'll be playing with time where that time represents what time an employee come to office and go home.

I'm a little bit confuse which data type i'll be used in this system.
Because there will be a lot of calculation according time data inside the database, such as: how many times an employee comes before 08.00, how much hours that he/she spend in the office that they, etc.

Can somebody help me with this problem, what data type most suitable with this kind of system and how can I do the calculation more easily?

thanx before,

View 3 Replies View Related

TIME - DATA TYPE IN SQL SERVER

Aug 10, 2005

Hi! I'va tried to find but I wasn't successful... I have a column in my database which I want it to be in minutes.seconds.cents of second... Is it possible to define this data type in sql server?
Thanks for any precious reply!

View 1 Replies View Related

Data Type To Store Time

Jun 15, 2007

Hi all ,

What datatype should I take to store time in a table -- datetime , float or decimal?

my requirement is to store "Worked Hours in a day by an employee" in the field say, 9 hrs and 30 mins.

I should be able to manipulate data in this field such as total hours present in the month, extra hours worked in a day (considering 9 hrs as standard time),less hours worked in a day, and so on



View 4 Replies View Related

Transact SQL :: Get Back (Identity) ID To The Other Table In SSIS Data Flow?

Jul 17, 2015

Table 1:

-------     -----                ----          ----
Name       Add                  No         RowID
-------     -----                 ----         -------

aa     #a-1,India                              10
bb     #a-1,India                              11                
aa     #a-1,India                              12

----------------------------------------------------

 table 1 inserting to Table 2 (Using 1st Data flow)

Table 2:

-------     -----                ----
Name       Add                 ID(Note:Here Identity1,1)
-------     -----                 ----
aa     #a-1,India                 1
bb     #a-1,India                 2
aa     #a-1,India                 3

----------------------------------------------------

My Requirement is Update  Table 1 set Column::No=Table 2.ID
                                                                       
based on Exact Match of
                                                                        
Table1.Name=Table2.Name  and
                                                                        
Table1.Add=Table2.Add

It means Get back the Id for Source Table 1

 2nd Data flow
             Source(Table1:Name, Add,No)
                          |

   --LOOKUP(Table2:Name, Add::Matched Look Columns Name, Add and
Tick Mark on ID)
                         |(Match)

   -->OLEDB Command: update Table1 set N0=? where  RowID=?(Here Param_0= NO ,Param_1=RowID)

Here My Issue is if  Table 1 had Duplicates(same Name, Add, but Row Id is different it is Updating Same ID for Table 1.No It means Get Back ID correctly not updating Result::

Table 1:

-------     -----                ----          ----
Name       Add                  No         RowID
-------     -----                 ----         -------
aa     #a-1,India                1              10
bb     #a-1,India                2              11                
aa     #a-1,India              1 12

----------------------------------------------------

My correct Output is     3      instead of Result:Table1 1.NO  1   where RowID =12

It caused by LOOKUP , It picking Top1 ID while Matching Look on fields.

How Should I update the (Identity) Get Back Table 2.ID to Source Table1. NO  in Above logic in SSIS?

View 11 Replies View Related

Reporting Services :: Adding Drill Through Parameters Increasing Rendering Time On Report Server

Nov 2, 2015

I have a report which takes around 5 seconds when run in BIDS but takes around 20 seconds when deployed on report server.Execution log says TimeDataRetrieval is around 3-4 seconds and  rendering time is around 15-17 secs.From this report I am passing 8 parameters to a  drill through report and there are 36 text boxes where I have defined these parameters for drill through action.All these parameters are populated in main dataset.When I deployed the same report without any drill through action and parameter, it takes 5 seconds.So I am suspecting that because of drill through parameters report is taking more rendering time on server.I am using 2008R2 and IE11.

Is it expected behavior that due to so many parameters for drill through action, report will take more rendering time?If yes, then why is it not taking same time in BIDS?

View 5 Replies View Related

Convert Data Type In SSIS Design Time

Oct 2, 2007

Hi, all experts,


Is there a way in SSIS dev environment that will let you convert/cast data type at desing time?


Under data flow mappings, there are so many things you can do, but why I did not find any easy way to convert?


I got this validation warning about not supportng converting type DT_STR to DT_I4, or something like that on many occassions..

I am using OLEDB Source as source and SQL Server Destination as destination.

Am I missing something obvious?


Thanks!

View 6 Replies View Related

Transact SQL :: Text Data Type Cannot Be Compared With Distinct

Oct 9, 2015

Field is not listed as text in any of the databases it is a varchar(255) - and that can be changed if that is what causes the issue.  

But here is my syntax which produces the error Msg 421, Level 16, State 1, Procedure, Line 2

The text data type cannot be selected as DISTINCT because it is not comparable.

DECLARE @c NVARCHAR(MAX)
WITH c1 AS (
SELECT [abcd] AS table_name
FROM [intranet].[dbo].[soccerfieldinfo]
where [abcd] IS NOT NULL
), c2 AS (
SELECT Row_Number() OVER (ORDER BY table_name) AS r

[Code] ....

View 3 Replies View Related

Transact SQL :: Converting Data Type Nvarchar To Bigint

Apr 17, 2015

This is a common error for SQL Server, but I got it in a uncommon way.I have a table called - tblIDNumber where there are two columns - IDN_Number [NVarchar(200)] and Temp [BigInt]

If I run,
SELECT  *
FROM    dbo.tblIDNumber
WHERE   IDN_IDNumberTypeStaticValue = 33
        AND IDN_Removed = 0
        AND CAST(IDN_Number AS BIGINT) = 1

SQL Server give me the error:
Msg 8114, Level 16, State 5, Line 1
Error converting data type nvarchar to bigint.

I first thought IDN_Number in type 33 has characters, but it doesn't, becasue the below query works!!!

UPDATE dbo.tblIDNumber
SET Temp = CAST(IDN_Number AS BIGINT)
WHERE  IDN_IDNumberTypeStaticValue = 33
        AND IDN_Removed = 0

To workaround, I ran the query,

UPDATE dbo.tblIDNumber
SET IDN_Number = '123'
WHERE  IDN_IDNumberTypeStaticValue = 33
        AND IDN_Removed = 0

and then I ran the first query, and SQL Server does NOT give me the same error - Msg 8114, Level 16, State 5, Line 1 Error converting data type nvarchar to bigint.

Second query approved there is nothing wrong from converting the value in IDN_Number to a BigInt, but the third query gave the hint that data might be the cause?????

finally, I found the root cause to be an index that the first query uses :

CREATE NONCLUSTERED INDEX [IX_tblIDNumber_Covering] ON [dbo].[tblIDNumber]
(
[IDN_Removed] ASC,
[IDNumberCode] ASC
)
INCLUDE ( [IDN_Number],
[IDN_Reference]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 85) ON [PRIMARY]
GO

If I remove the index, the first query works without the error.

View 10 Replies View Related

Transact SQL :: Load JSON Type Data To Server

Jan 15, 2012

Tried loading JSON data to Sql Server  ? Sample format is given below..Don't see any easy way doing it except writing some C# code deserialize it.
 
[ {
  "name" : "peter_2.jpg",
  "createdDate" : 1259728960000,
  "lastModifiedDate" : 1308174976000,
  "Secondary" : [ {
    "Id" : 106275817,
    "Sid" : 1
   
[code]...

View 8 Replies View Related

Transact SQL :: Change Data Type In All Fields In Database

Sep 25, 2015

I want change all field in database to new datatype.I want change data from Small Integer to Integer but there are the relation in each table.

View 3 Replies View Related

Transact SQL :: Conversion Failed When Converting Varchar Value NHS To Data Type Int

Sep 3, 2015

CASE WHEN NULLIF(NHSNo2, '') IS NULL THEN 1
WHEN NULLIF(Surname, '') IS NULL THEN 2
WHEN NULLIF(Forename, '') IS NULL THEN 3
WHEN NULLIF(DOB, '') IS NULL OR DOB < '01/01/1900' THEN 4
WHEN NULLIF(AddressLine1, '') IS NULL THEN 5

[code]...

The above code worth great but ideally instead of returning a number Id like to return text for example

1 = NHS
2= SUR
3=FOR
4=DOB
5=ADD
6=PCO
7=GPN
8=PCZ
9=GPD
10=CCG

View 3 Replies View Related

Transact SQL :: ERROR Converting Data Type Varchar To Numeric

Nov 17, 2015

Below is garbage data and structure (I think enough to get point across).  How can I perform calculations needed?

Create Table #1234
(
abcd decimal(16,4)
,defg decimal(16,4)
,hijk decimal(16,4)
,logon datetime
,logoff datetime

[code]....

View 2 Replies View Related

Transact SQL :: Error Converting Data Type Nvarchar To Float

Sep 24, 2015

In the following code I want to compare 2 values: AccessVal and SQLVal. The values are stored as nvarchars, so I'm isolating the numeric values in a subquery. Notice I'm only selecting 1 row. The commented line, where I compare the values, is throwing the error.

SELECT QA_AutoID, AccessVal, SQLVal
,ROUND(ABS(CONVERT(float, AccessVal,1)),0) as AccessFloat
,ROUND(ABS(CONVERT(float, SQLVal,1)),0) as SQLFloat
FROM QA
WHERE QA_AutoID in (
SELECT TOP 1 QA_AutoID
FROM QA
WHERE ISNUMERIC(SQLVal) = 1 AND ISNUMERIC(AccessVal) = 1
)
--AND ROUND(ABS(CONVERT(float, AccessVal,1)),0) <> ROUND(ABS(CONVERT(float, SQLVal,1)),0)
ORDER BY ROUND(ABS(CONVERT(float, AccessVal,1)),0) DESC
,ROUND(ABS(CONVERT(float, SQLVal,1)),0) DESC

Here is the output with the comparison commented out...

Here's what I get with the comparison line activated:

I've tried converting to numeric, int and bigint instead of float. I've tried CAST instead of CONVERT. Nothing works.

View 13 Replies View Related

Transact SQL :: Conversion Failed When Converting Varchar Value To Data Type Int

Nov 13, 2015

i am trying to run to get a list of computers from a table based on the available free space. I'd like to group them based on the available space, for example, up to 1 GB, 1-2 GB, etc. 

With Disk_Space (ResourceID, ComputerName, Description, DiskName, VolumeName, FileSystem, Size, FreeSpace)AS
(
SELECT distinct
SYS.ResourceID,
SYS.Name,
LDISK.Description0,
LDISK.DeviceID0,
LDISK.VolumeName0,
LDISK.FileSystem0,

[code]...

However when i run this query, i get an error : 
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '1GB To 2GB' to data type int.

View 10 Replies View Related

Strange Data Type Displayed On Time Series Algorithm Model

Jun 5, 2007

Hi, all,

Again I encountered a very strange problem which displayed the predicted attribute values as percentage format? The data type of the attribute is actually double, why is that?

That's really frustrated.

Thanks a lot in advance for your kind advices and I am looking forward to hearing from you shortly.

With best regards,

Yours sincerely,

View 3 Replies View Related

Transact SQL :: Arithmetic Overflow Error Converting Expression To Data Type Int

Oct 16, 2013

this query is running fine in 2008 , but its not working in 2005 below is the error Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type int.there is some problem in converting date in cte

with a 
as 
(
SELECT dbname = DB_NAME(database_id) ,
       [DBSize] = CAST( ((SUM(ms.size)* 8) / 1024.0) AS DECIMAL(18,2) ) 
       ,
COALESCE(CONVERT(VARCHAR(12), MAX(bus.backup_finish_date), 101),'01/01/1900') AS LastBackUpTime
FROM   sys.master_files ms
inner join msdb.dbo.backupset bus ON bus.database_name = DB_NAME()

[code]....

View 9 Replies View Related

Transact SQL :: Conversion Failed When Converting Varchar Value (Date) To Data Type Int

Sep 2, 2015

I am using T-SQL I have a column (ColA)that has datetime format and I simply want to pull the next day but date only into ColB

ColA
3/12/2014 12:00AM
3/19/2014 12:00AM
ColB
3/13/2014
3/20/2014

I have been trying the command below but keep getting the error "Conversion failed when convertint the varchar value '03-03-2014' to data type int."

Convert (varchar(10), "StartDate", 110)+1 as Next Day

View 8 Replies View Related

Transact SQL :: Conversion Failed When Converting Varchar Value (inactive) To Data Type Int

Jul 20, 2015

I am getting this error when I run the case statement below. I think I have to convert at some point, but not sure where or how. 

Case when m.dispo = 2 then 'Inactive' else m.value end 'Score'

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved