identity

How to get identities of inserted data records using SQL bulk copy

孤人 提交于 2019-12-21 09:07:17
问题 I have an ADO.NET DataTable with about 100,000 records. In this table there is a column xyID which has no values in it, because the column is an auto-generated IDENTITY in my SQL Server database. I need to retrieve the generated IDs for other processes. I am looking for a way to bulk copy this DataTable into the SQL Server database, and within the same "step" to "fill" my DataTable with the generated IDs. How can I retrieve the identity values of records inserted into a table using the

How to retrieve server generated Identity values when using SqlBulkCopy

空扰寡人 提交于 2019-12-21 04:41:21
问题 I know I can do a bulk insert into my table with an identity column by not specifying the SqlBulkCopyOptions.KeepIdentity as mentioned here. What I would like to be able to do is get the identity values that the server generates and put them in my datatable, or even a list. I saw this post, but I want my code to be general, and I can't have a version column in all my tables. Any suggestions are much appreciated. Here is my code: public void BulkInsert(DataTable dataTable, string

How to grant identity ApplicationPoolIdentity read rights to folder within my site

微笑、不失礼 提交于 2019-12-21 04:31:25
问题 On our Windows 2008 R2 server I have a site running under the default ASP.NET v4.0 application pool. The identity of ASP.NET v.4.0 app pool is set to "ApplicationPoolIdentity" (I guess this is default). How do I grant this identity access to read from a custom folder within my site. I have tried "Application Pool Identity" and "ApplicationPoolIdentity" but both gives me: An object named "Application Pool Identity" cannot be found. Bonus question = should I instead forget about all this and

How to grant identity ApplicationPoolIdentity read rights to folder within my site

一世执手 提交于 2019-12-21 04:31:12
问题 On our Windows 2008 R2 server I have a site running under the default ASP.NET v4.0 application pool. The identity of ASP.NET v.4.0 app pool is set to "ApplicationPoolIdentity" (I guess this is default). How do I grant this identity access to read from a custom folder within my site. I have tried "Application Pool Identity" and "ApplicationPoolIdentity" but both gives me: An object named "Application Pool Identity" cannot be found. Bonus question = should I instead forget about all this and

Handling identity columns in an “Insert Into TABLE Values()” statement?

本小妞迷上赌 提交于 2019-12-21 03:09:34
问题 In SQL Server 2000 or above is there anyway to handle an auto generated primary key (identity) column when using a statement like the following? Insert Into TableName Values(?, ?, ?) My goal is to NOT use the column names at all. 回答1: By default, if you have an identity column, you do not need to specify it in the VALUES section. If your table is: ID NAME ADDRESS Then you can do: INSERT INTO MyTbl VALUES ('Joe', '123 State Street, Boston, MA') This will auto-generate the ID for you, and you

Advice Please: SQL Server Identity vs Unique Identifier keys when using Entity Framework

那年仲夏 提交于 2019-12-21 02:47:31
问题 I'm in the process of designing a fairly complex system. One of our primary concerns is supporting SQL Server peer-to-peer replication. The idea is to support several geographically separated nodes. A secondary concern has been using a modern ORM in the middle tier. Our first choice has always been Entity Framework, mainly because the developers like to work with it. (They love the LiNQ support.) So here's the problem: With peer-to-peer replication in mind, I settled on using uniqueidentifier

Inserting a row and retrieving identity of new row in SQL Server CE

别说谁变了你拦得住时间么 提交于 2019-12-21 01:30:13
问题 I'm trying to insert a row and get back the new row's identity with something like this: INSERT INTO blah....; SELECT @@IDENTITY as NewID; I'm trying to execute both statements with a single invocation of a DbCommand object in C#... it doesn't seem work or I've got something wrong. I've read that Compact Edition doesn't support executing multiple statements in a batch... but I also found this: If you want to run multiple queries simultaneously, you must include a new line character for each

Change username in MVC 5

淺唱寂寞╮ 提交于 2019-12-20 20:41:58
问题 I am using ASP.NET MVC5 and Identity 2.0 (beta). It is possible for users to change the username? I am trying using UserManager.UpdateAsync method throws an exception. Regrads, Fran. 回答1: Yes it is possible using the UpdateAsync method but you need to ensure that you update both the email and username fields. var user = userManager.FindById(userId); user.Email = email; user.UserName = email; var updateResult = await userManager.UpdateAsync(user); This method works successfully for me 回答2:

What happen in SQL 2005 when it run out of number for an autonumber column?

泪湿孤枕 提交于 2019-12-20 19:58:43
问题 What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? What is the behavior of SQL Server 2005 when it happen? 回答1: You will get an overflow error when the maximum value is reached . If you use the bigint datatype with a maximum value of 9,223,372,036,854,775,807 this will most likely never be the case. The error message you will get, will look like this: Msg 220, Level 16, State 2, Line 10 Arithmetic

What happen in SQL 2005 when it run out of number for an autonumber column?

那年仲夏 提交于 2019-12-20 19:58:09
问题 What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? What is the behavior of SQL Server 2005 when it happen? 回答1: You will get an overflow error when the maximum value is reached . If you use the bigint datatype with a maximum value of 9,223,372,036,854,775,807 this will most likely never be the case. The error message you will get, will look like this: Msg 220, Level 16, State 2, Line 10 Arithmetic