|
Mind-reading is a great feature to have. This way you know what I want better than me... oh wait; you don't and yet you assumed otherwise anyway
|
|
|
|
|
Why don't you just try it and find out for sure instead of being rude to people trying to help.
BEGIN TRANSACTION
INSERT something INTO table
ROLLBACK TRANSACTION
|
|
|
|
|
I do know, and I did tell you to rethink your design.
If you had used Oracle it would have been much worse, Oracle cache the sequences, so if you restart the server you can get a gap of twenty numbers. and if you have a cluster server they won't even be in order.
(<for the nitpicks> I know it's a setting, but if you want higher performance you don't change it</for the nitpicks>)
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|
The new IDENTITY value is generated when a row insert is initiated and will update the table's current identity value even when the transaction is rolled back. In simple terms, it would behave as if no rollback happened.
|
|
|
|
|
Thanks guys. Exactly what I needed to find out.
|
|
|
|
|
Identity (auto-increment) is not part of the transaction, so isn't rolled back. In your example, the ID for the next call would be 102.
|
|
|
|
|
Thanks guys. Exactly what I needed to find out.
|
|
|
|
|
While Shameel and Russel gave you answers it is not the solution, if you are relying on the identity filed to give you sequential information (or any information) your design is WRONG. An ID field has only 1 function, to identify the record.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Hi,
I think You are asking about "IDENTITY" Property in SQL Server right. If you will use IDENTITY while creating table, It will Increment Automatically based on your Starting value and Increment.
For Example,
CREATE TABLE #T1 (ID INT NOT NULL IDENTITY(1,1), Name VARCHAR(12))
INSERT INTO #T1(Name) VALUES('A')
SELECT * FROM #T1
BEGIN TRAN T1
INSERT INTO #T1(Name) VALUES('B')
ROLLBACK TRAN T1
INSERT INTO #T1(Name) VALUES('C')
SELECT * FROM #T1
So Once Identity values is Incremented, In case If Transaction Roll backed also you will get next value only.
Regards,
GVPrabu.
|
|
|
|
|
I am planning on learning about SQL. However, there seems to be no good quality tutorials that I can find on the internet.
Are there any recommended books for SQL beginners?
Thanks
=====
\ | /
\|/
|
|-----|
| |
|_ |
_) | /
_) __/_
_) ____
| /|
| / |
| |
|-----|
|
=====
===
=
|
|
|
|
|
SQL for smarties by Joe Celko.
It's deceptively simple but lasts a long way.
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|
If you are using SQL Server 2008 or later, I suggest you try T-SQL Fundamentals for Microsoft SQL Server by Itzik Ben-Gan.
|
|
|
|
|
I also read articles from http://www.sqlservercentral.com/[^] and they have a good Question of the Day feature that gets emailed to you daily so that you can test your knowledge etc.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
You need to decide what start with. Do you want a general overview? To learn to code (T-SQL)? To learn how to be a DBA? Do you want a certificate?
I would go to a bookstore with a good computer section and look at the SQL books. As an example, have a question in mind, say for T-SQL, lookup data types. If you can understand what they say, that book would be high on the possible list.
|
|
|
|
|
Hi,
Check the following Books.
-- Book 1
Book Name : Beginning SQL Server 2008 for Developers From Novice to Professional Jul 2008
Authors : Louis Davidson, With Kevin Kline, Scott Klein, and Kurt Windisch
Publisher : APress
-- Book 2
Book Name : Pro-T-SQL-2008-Programmers-Guide-Experts-Voice-in-SQL-Server
Author : Michael Coles
Publisher : APress
Regards,
GVPrabu
|
|
|
|
|
Hi..
Recently i created Session State in my project, code is here..
<sessionState mode="SQLServer"
allowCustomSqlDatabase="true"
sqlConnectionString="Data Source=ADMIN-9F8C57749\SQLEXPRESS;Initial Catalog=kecbliss;Integrated Security=True"
timeout="60"
stateNetworkTimeout="60">
</sessionState>
the problem is day by day aspstatetempsessions table is becoming big
so my question is
1.can i delete previous days records from aspstatetempsessions?
2.How to achieve this without affecting to project ?
project details
front end ASP.NET
Back end MS SQL Server
|
|
|
|
|
|
hi all,
I am new database designer, and now i want to design database that can control avg cost and close stock.could you give me an idea? and please tell me the way to calculate avg cost every transaction(ex: sale,purchase,....) include Item avg cost and report. It is really difficult for new database designer like me. Thank in advanced.
|
|
|
|
|
|
I can't find the answer to this MySQL question in the documentation:
If I execute "LOCK TABLES" through an ODBC connection, and a different thread already holds a lock on the specific table, does the calling thread block until the lock is acquired, or does the call simply fail and return immediately?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I don't know the answer either. (I would assume it waits)
But check if you can use named locks[^] instead, then your application can name the lock and check if another instance have made a lock with the same name or not.
But watch out, there are a lot of pitfalls. So read the manual properly.
People say nothing is impossible, but I do nothing every day.
|
|
|
|
|
I need some help with an SQL query I’ve been asked to create.
Due to lack of communication, an update was done incorrectly and now needs to be fixed (surprise, surprise ). Each employee has 5 Ben_Codes and the start date for all Ben_Codes needs to be equal to the start date of Ben_Code 1. The dates are not constant so for each employee I need to read Ben_Code 1 record to retrieve start_date and then update Ben_Codes 2 thru 5 with that start_date.
To this point I have done very basic updates using SQL Query and would appreciate any guidance you can provide!!
Emp_id, Ben_Code, start_date
99999 1 10/12/12
99999 2 01/12/13
99999 3 01/12/13
99999 4 01/12/13
99999 5 01/12/13
98989 1 9/15/2012
98989 2 01/12/13
98989 3 01/12/13
98989 4 01/12/13
98989 5 01/12/13
|
|
|
|
|
|
Yes, SQL Sever
Left that important bit of info out
|
|
|
|