Can IDENTITY Value Be Changed?

Jun 19, 2001

I have an IDENTITY value in a table that was incorrectly created, and needs to be modified. Can this be accomplished?

Thanks.

View 1 Replies


ADVERTISEMENT

Has SELECT INTO With IDENTITY() Function Changed The Way #'s Are Assigned?

Oct 10, 2007

We have SELECT INTO queries that use the IDENTITY function to assign a sequential row number to a result set based upon a sort order. This has been helpful in SQL Server 2000 for median determination. It appears, however, that in SQL Server 2005, the row numbers are not assigned sequentially, or maybe they are assigned before the sort order is applied.

Can anyone verify whether the IDENTITY function has changed behavior between 2000 and 2005? We would prefer not to have to make changes to existing queries. Thank you.


(BTW, the workaround we found so far is to put the initial SELECT...ORDER BY in a subquery, but then we had to include a phrase like TOP 10000000 to pass syntax check. Is there a better way?)

View 4 Replies View Related

Last GASP On Insert Row In Table With Identity Field, And Get New Identity Back ?

Jul 9, 2006

While I have learned a lot from this thread I am still basically confused about the issues involved.

.I wanted to INSERT a record in a parent table, get the Identity back and use it in a child table. Seems simple.

To my knowledge, mine would be the only process running that would update these tables. I was told that there is no guarantee, because the OLEDB provider could write the second destination row before the first, that the proper parent-child relationship would be generated as expected. It was recommended that I create my own variable in memory to hold the Identity value and use that in my SSIS package.

1. A simple example SSIS .dts example illustrating the approach of using a variable for identity would be helpful.

2. Suppose I actually had two processes updating these tables, running at the same time. Then it seems the "variable" method will also have its problems. Is there a final solution other than locking the tables involved prior to updating them or doing something crazy like using a GUID for the primary key!

3. We have done the type of parent-child inserts I originally described from t-sql for years without any apparent problems. (Maybe we were just lucky.) Is the entire issue simply a t-sql one or does SSIS add a layer of complexity beyond t-sql that needs to be addressed?



TIA,



Barkingdog

View 10 Replies View Related

Insert Row In Table With Identity Field, And Get New Identity Back

Jun 30, 2006

I want to insert a new record into a table with an Identity field and return the new Identify field value back to the data stream (for later insertion as a foreign key in another table).

What is the most direct way to do this in SSIS?



TIA,



barkingdog



P.S. Or should I pass the identity value back in a variable and not make it part of the data stream?

View 12 Replies View Related

T-SQL (SS2K8) :: How To Update Identity Column With Identity Value

Jan 25, 2015

I have table of three column first column is an ID column. However at creation of the table i have not set this column to auto increment. Then i have copied 50 rows in another table to this table then set the ID column values to zero.

Now I have changed the ID column to auto increment seed=1 increment=1 but the problem is i couldn't figure out how to update this ID column with zero value set to each row with this auto increment values so the ID column would have values from 1-50. Is there a away to do this?

View 6 Replies View Related

Identity...I Need To Get The Last (or Highest Number In Identity Column)...

Sep 19, 2005

Ok,I just need to know how to get the last record inserted by the highestIDENTITY number. Even if the computer was rebooted and it was twoweeks ago. (Does not have to do with the session).Any help is appreciated.Thanks,Trint

View 2 Replies View Related

Problem In Using Sqlbulkcopy To Insert Data From Datatable(no Identity Column) Into Sql Server Table Having Identity Column

Jun 19, 2008

Hi,
I am having problem in bulk update of a sql server table haning identity column from a datatable( has no identity column) using sqlbulkcopy. I tried several approaches, but it does not show any error nor is the table getting updated. But the identity value seems to getting increased every time.
thanks.
varun

View 6 Replies View Related

How To Use Identity On Non-identity Column (with Concurrence)

Aug 1, 2014

I'm working with a third-party database (SQL Server 2005) and the problem here is the following:

- There are a bunch of ETL processes that needs to insert rows on a table (let's call this table T) and at the same time, an ERP (owner of T) is up and running (reading, updating and inserting on T).

- The PK of T is an Integer.

Today all ETL processes uses (select max(ID) + 1 from T) to insert new rows, so just picture the scenario. It is a mess! Everyday they get duplicate key error when 2 or more concurrent processes are trying to insert a row (with the max) at the same time.

Considering that I can't change the PK, what is the best approach to solve this problem?

To sum up:

* I need to have processes in parallel inserting on T

* I can't change anything on T

* The PK is NOT an Identity

View 4 Replies View Related

CHanged Objects

Dec 7, 1999

Is there a way to produce a query to look at when and who changed database objects last?

View 1 Replies View Related

Allow Nulls Cannot Be Changed

Apr 9, 2003

I have a table as part of a replicated database where i need to change the allow nulls value (set it to not allow nulls) but when i try to save the table i get this error.

'CONTACTS' table
- Unable to modify table.
ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot drop the table 'dbo.CONTACTS' because it is being used for replication.

will i have to stop replication to make the change or is it worse and i have to delete the publication and start all over again?

View 7 Replies View Related

Cell Changed Each Less Than 1 Sec

Feb 1, 2008

hi all
im really have a problem in my project.
i have server and client side each side contain SQL Server DB.
and i have excel file on the server side this excel file conected with another server, this file changed data in continuosly each less than 1 sec by data feed.

now i need to read each changed data cell from this file to save it on server DB and Client DB (just changed data).

my problem :

u know changed event is not fired when change cell by data feed or not edit manually, just calc event is rised . but calc event do not specify the changed cell range (address).

so i do this to know changed cell range:
when run the program saved all excel tabel into SQL server table.
and then check row by row between excel and sql if any change , when i get any change, i update the excel row insted this DB row.

and rise event to send this row to client by socket over internet to update the row in client side too.

but i tell u that the excel file updated each less than 1 sec, and i noted that many changed excel data missed until checked row by row for whole excel sheet with DB tabel and updated change.

this is my problem ( please help me as soon as posible coz i have dead line to Delivered this program)

and if u recomended me for another techneque to be easy or quickly to solve this problem i will thaks so much for u)

thank u.
AL-Khateeb

View 3 Replies View Related

TNS Alias Name Changed

Jan 22, 2007

Maybe somebody has asked this question, but I could not find it....

I used SSIS to transfer data from Oracle database to SQL Server 2005 (with Microsoft OLE DB Provider for Oracle). It worked fine with the TNS alias name said oracle1. Then I changed the TNS alias name to oracle2. I could connect to Oracle database with oracle2 using Oracle's tool. But SSIS could not find (or solve) oracle2, if I changed the name back to oracle1 in SSIS, then SSIS worked.

Any idea?

Thanks!

View 7 Replies View Related

File Name To Be Changed

May 21, 2007

Hello,



I have developed a report based on a stored procedure which will generate an excel file. There is a requirement that this file needs to be sent to an external domain with the name changed accordingly i.e., a date is to be suffixed to the file after the name has been changed based on their naming convention.



I would appreciate, if anybody has done so and can give me some steps for me to work out.



TIA

View 3 Replies View Related

Where And How Can Timeout Settings Be Changed

Nov 6, 2006

I have a page that uses an SQLDataSource web control to populate a GridView control.  The SQLDataSource control uses three parameters, one of which is a text string (varchar(50)).  I get timeout expired exceptions when I run the page with two specific string values, yet when I run the stored procedure in SqlSvr Management Studio, the procedure runs in 5 seconds and under 1 seconds.  Being rnew to ASP.NET 2.0 and .Net in general, I have no idea where this lag is occurring.  I would like to know two things:
1.  What is causing the lag that causes the timeout in ASP.NET 2.0.
2.  What can be done to adjust the timeout period SQLSVR, IIS, ASP.NET).
The underlying query is running as desired (considering the data it has to chew on).  For all other values, data is returned almost instantanious.  I can provide a copy of the query id need be.
 Truly appreciate any insight you can give me!

View 2 Replies View Related

Changed From Char To Varchar

Jun 3, 2004

i changed my state table from char 20 to varchar 20 and it still fills it with empty space at the end of the statename
I tried entering it with the trim command still no good
i looked a the sql command made in vs and it says that the variables are varchar
is there something i am missing with varchar
does it only work properly if it is over 50 or does it not change completely when you change from char to varchar

View 2 Replies View Related

SQL Does Not Start After The Server Name Is Changed

Mar 4, 2002

Is there any way to reconfigure SQLSERVER if the name of the server was changed after the initial installation of Sql was completed?

View 2 Replies View Related

The IP Address Of Our SQL Server Is To Be Changed

Apr 22, 2003

Hello,

Soon, we are going to redesign our servers and their positioning insofar as web access is concerned. The SQL Server will go to a DMZ.

Its IP Address (as well as hostname) is to be changed. Can you offer suggestions about what to be aware of on these two items?

I've been involved in a hostname change befoew (and, it's a pain), but never an IP Address.
Thanks, MichaelG

View 2 Replies View Related

Varchar Value Changed To Unicode

Aug 8, 2005

i have table Table1 with column lastname ,firstname ect.The Data type is varchar.
I have inserted values. I have selected records from this table and assign this records to the TDC control of the HTML .The query returns 130 records.The TDC control has the Unicode delimiter. Whene we select top 7 ,seven records are displayed ,when it is top 8 it does not show any records.
If we delete the Lastname and Firstname values for this 8th record then all the 130 records are displayed.
Why is this happning.Any great minds can help me in this pls

View 3 Replies View Related

How To Find Who Has Changed The Record

Aug 14, 2001

Is there any method so that I can find that the particular user has changed the record in the particualr table..?

View 1 Replies View Related

#Deleted When A Record Is Changed

Feb 1, 2008

First of all, let me apoligize if this is a stupid question, but just a few days ago I decided to change my FE/BE database from Ms Access to SQL Server Express. Now I have a FE in ACC2002 and a BE in SQL SERVER (the two connected via ODBC). Anyway, this is my question:

When everything was in Access I had a form retreiving a series of records based on a filter - for understanding purpose let's say that a field must have been 'Not Null'. The operator then filled that field with data. With Access everything was static, and the operator could see all the records, the ones already changed and the ones not changed. With SQL now: everytime the operator fills in the field, the record changes to #Deleted. I assume that that is happening because the query - someway - is "alive" and is "filtering data alive"... or is updating records instantly. Just to make things more clear: is the record changed immediately so it is not considered part of the filtered data by the query, thus being change to #Deleted? What could I do to prevent this?

Thanks a lot for your help.

View 3 Replies View Related

Get The Latest Changed Records

Feb 13, 2008

Hi,

I hava a table with the following information

CREATE TABLE TEMP1 (REFID INT, REVISION INT, FIELDNAM VARCHAR(10), VALUE VARCHAR(10));
INSERT INTO TEMP1 VALUES(1001, 0, 'A', 'A2');
INSERT INTO TEMP1 VALUES(1001, 0, 'C', 'C2');
INSERT INTO TEMP1 VALUES(1001, 0, 'E', 'E2');
INSERT INTO TEMP1 VALUES(1002, 0, 'A', 'A3');
INSERT INTO TEMP1 VALUES(1002, 0, 'B', 'B2');
INSERT INTO TEMP1 VALUES(1002, 0, 'E', 'E3');
INSERT INTO TEMP1 VALUES(1001, 1, 'A', 'A4');
INSERT INTO TEMP1 VALUES(1001, 1, 'E', 'E4');

Here based on latest revision and refid I should get the fieldnam and value.
Expected output:
REFID FIELDNAM VALUE REVISION
1001 A A4 1
1001 E E4 1
1002 B B2 0
1001 C C2 0

View 7 Replies View Related

Changed Table Structure

Mar 1, 2004

Hi all,

How can i get the information as to when was the last my particular table structure was changed (for ex. adding of a column/dropping a column)

Pls let me know
TIA

View 3 Replies View Related

Import Only Yhe Changed Data

Mar 30, 2004

I want to import via DTS to big table only the records that changed last day. can i do it without a time field? because this is a key table for DWH and not a fact table.
THX
Inon

View 4 Replies View Related

Procedure Last Changed Date

Oct 15, 2005

I am trying to find the last changed date for a procedure. I have located the date created in the sysobjects table (crdate). Is this available?

View 8 Replies View Related

Today's Date/Changed

Mar 19, 2006

Okay, 2 questions here.

First I want to query everyone with a date greater than today in the field EXPIRATION DATE. I know I can say > 2006-03-19 but I always want it to be TODAY.

Next, Is there a system field that I can search for the date a record was last updated?? I make frequent changes, and I want others to see what date a record was last updated. If not, can I tell the system to mark a field "YES" when I make changes?

I use phpmyadmin. I do not have server access, just through PHP.

Thanks!
TV

...The TIger has ROARED

View 10 Replies View Related

Selecting Changed Rows Only

Jul 23, 2005

Hi experts,I have been trying to limit the table rows in the following situation,any suggestions will be appreciated.we have table called tempTb has columns id, c_id, c_name, rating, datecolumns.id is an identity column.date is a datetime column, the rest are varchar datatype.Here is the table structure with sample data,idc_idc_nameratingdate1aoamer onli11/1/20022aoamer onli13/1/20023aoamer onli16/1/20024aoamer onli39/1/20025aoamer onli312/1/20026aoamer onli33/1/20037aoamer onli36/1/20038aoamer onli39/1/20039aoamer onli212/1/200310aoamer onli16/1/200411aoamer onli112/1/200412xyxabs yasd11/1/200213xyxabs yasd23/1/200214xyxabs yasd26/1/200215xyxabs yasd29/1/200216xyxabs yasd112/1/200217xyxabs yasd13/1/200318xyxabs yasd36/1/200319xyxabs yasd39/1/200320xyxabs yasd212/1/200321xyxabs yasd16/1/200422xyxabs yasd112/1/2004[color=blue]>From this table I need to select the rows with rating changes only,[/color]i.e if two or three consecutive rows have same rating only the firstrow should be selected.the selection should look like...idc_idc_nameratingdate1aoamer onli11/1/20024aoamer onli39/1/20029aoamer onli212/1/200310aoamer onli16/1/200412xyxabs yasd11/1/200213xyxabs yasd23/1/200216xyxabs yasd112/1/200218xyxabs yasd36/1/200320xyxabs yasd212/1/200321xyxabs yasd16/1/2004I was trying to do this by self-joining the table like....select t1.* from tempTb t1, tempTb t2where t1.id!=t2.id,t1.c_id=t2.c_id,t1.c_name=t2.c_name,t1.rating!=t2.rating.But this is generating cartesian products,I have tried some other combinations after where clause with date colmnwtc,but none seems to give the required result.so if anybody can guide me in the right direction I would appreciateit.Thanks alot,Remote

View 4 Replies View Related

Only Update Changed Columns

Aug 15, 2006

I have a stored procedure that inserts values into five columns of atable. I need another stored procedure that will allow the user to passone or more of those parameters and update only the column for the datathat was passed. In other words, the update may only have one or two ofthe parameters that was originally provided in the insert. Therefore, Ido not want to update the columns that did not change. What is theproper way to handle this situation?

View 1 Replies View Related

Finding Changed Records

Jul 20, 2005

I need to create a table that would be the result set of a comparisonbetween table a and table b? Table a and b first 2 fields will always bethe same (CustomerName and CustomerNumber). But if the Address1 fieldchanges in table a, I would like to throw that whole row into mycomparison table. Almost like a Select Into with a sub query that wouldinclude a WHERE TableA.field <> TableB.field. I would need to do thiscomparison for about 8 fields. Help appreciated for my syntax is prettybad. Thanks.Steve*** Sent via Developersdex http://www.developersdex.com ***Don't just participate in USENET...get rewarded for it!

View 1 Replies View Related

SQL Trigger For Changed Columns?

Jul 20, 2005

I have never written a trigger before and now am seeing the light. Isthere a way to write a trigger so that if a user changes any column ina single row on one table then the trigger will write the value ofthis (these) rows to a second table. I don't want the unchangedcolumns, just the changed columns (with column names...)Thanks,lq

View 10 Replies View Related

Can Table Ownership Be Changed?

Jul 20, 2005

When I create tables in SQL I can specify dbo as the owner using thesyntax below but when using the upsize wizard in Access 2000 I owneverything. Is there a way that the system administrator can changeownership after the fact?CREATE TABLE dbo.mytable (c1 int not null)Thank You,Randy KJoin Bytes!

View 1 Replies View Related

Password For Sa Was Changed Spontaneously

Jul 20, 2005

Hello!We are running MS SQLServer 7.0 with ASP on Win 2k Server.Today suddenly the Web server couldn't connect to the DB Serverbecause the password for sa was wrong.We found out that the password was changed.Is it some kind of hacking thing or just normal password expiration?The same thing happended several month ago.Thanks.Sam

View 1 Replies View Related

Update Only Changed Columns

Sep 25, 2007

i there,

I've got a problem With updates on a Table.

I want to update only the Columns which are different to the values of my update-Statement.

One of the problems is an update trigger , which is fired on all update statements.
I want the trigger to be fired only when there are real changes.
Of course i can retrospectively check if there was a real, but i can't devide the real updatet colums from the non changed values. I know there is a statement like RowsUpdated but it doesn't work that way. It indicates also the non changed columns. To lock the row pessimistic read and compare the contents before update is also no option for me.

Is there any command to perform this in a smart way? Or should it be suggested for the next version of SQL-Server like "UPDATE CHANGES MY_TABLENAME SET MY_COLUMN= ... "

thanks in advance
Raimund


View 4 Replies View Related

Updating Only Changed Fields

Sep 6, 2007

My client wants to minimize concurrency issues by only updating fields that the user actually changed. Whereas most update stored procedures I have created just updated all of the fields WHERE key=value, they want to update individual fields.

What I came up with so far does not look very efficient and I was wondering if anyone has suggestions for improvement.

Here is a snippet from the stored proc script:



Code Snippet
CREATE PROCEDURE dbo.DriverSaveChangedColumns
@DriverNumber VarChar(10) OUTPUT,
@CompanyName VarChar(50),
@DriverName VarChar(50),
@Address1 VarChar(50),
...
IF @CompanyName <> @Org_CompanyName

BEGIN

UPDATE Driver
SET DR_CompanyName = @CompanyName
WHERE DR_DriverNumber = @DriverNumber AND DR_CompanyName = @Org_CompanyName
END

IF @DriverName <> @Org_DriverName

BEGIN

UPDATE Driver
SET DR_DriverName = @DriverName
WHERE DR_DriverNumber = @DriverNumber AND DR_DRiverName = @Org_DriverName
END
...



Any suggestions?

The only other thing I thought of is to forget the stored procedure and do inline SQL ... but I'd rather have a proc.

Thanks!

View 15 Replies View Related







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