473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to fetch primary key after an insert command? (MS SQL 2005 Express)

Hi

I am a novice in MS SQL 2005 Express and would like to know how to fetch a primary key after an insert command. I have used MYSQL and there you have a command that covers this function. I am using C# and ASP.NET 2.0.
Is there something similar in MSSQL?

Thanks for you reply.

Regards
Arno
Jun 29 '07 #1
4 3038
kestrel
1,071 Expert 1GB
Please do not post questions in the Articles Section. I have moved this to the Forum.

--
Kestrel
Jun 29 '07 #2
Motoma
3,237 Expert 2GB
Hi

I am a novice in MS SQL 2005 Express and would like to know how to fetch a primary key after an insert command. I have used MYSQL and there you have a command that covers this function. I am using C# and ASP.NET 2.0.
Is there something similar in MSSQL?

Thanks for you reply.

Regards
Arno
Please take a look at this link and come back if you have any more questions.
Jun 29 '07 #3
Hi

I am a novice in MS SQL 2005 Express and would like to know how to fetch a primary key after an insert command. I have used MYSQL and there you have a command that covers this function. I am using C# and ASP.NET 2.0.
Is there something similar in MSSQL?

Thanks for you reply.

Regards
Arno

Hi,

I assume you want the last insert record ( primary key) ?

Let me know and I will help you with the code?

Cheers.
Jul 2 '07 #4
Hi,

I assume you want the last insert record ( primary key) ?

Let me know and I will help you with the code?

Cheers.

Please find below the code to find the last inserted record:


CREATE PROCEDURE name
(
@ID int OUTPUT
)
AS
INSERT INTO Table1
(DateCreated)
VALUES
( GETDATE() )
SET @ID = SCOPE_IDENTITY()
;
Jul 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

48
by: ik | last post by:
ERROR after uninstalling SQL Server 2005 Express I get this message, SQLDMO has not been registered. Please re-run your setupand contact your system administrator. GREAT!!! ReInstalled SQL...
0
by: gerd | last post by:
Hello, I want to port an MFC Application from Visual Studio 6 MFC application to Visual C++ 2005 express edition beta. While building i get following error: ------ Build started: Project:...
10
by: Bonj | last post by:
Hi I installed .NET 2005 express edition, and am about to unnistall it again because it can't seem to be able to even insert a resource file into a project. Can anyone tell me is this right?...
1
by: Peted | last post by:
Hi, sorry if this isnt the correct newsgroups for this questions but im using vc++ 2005 express edition beta2 for learning to program vc++ ..net, as in winforms applications and i was wondering...
45
by: mistral | last post by:
Does Visual C++ 2005 Express Edition produce small, compact C executables? Or there is another C compilers that do this better? m.
5
by: mabond | last post by:
Hi VB.NET 2005 Express edition Microsoft Access 2000 (SP-3) Having trouble writing an "insert into" command for a Microsoft table I'm accessing through oledb. I've tried to follow the same...
3
by: iKiLL | last post by:
Hi all I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile Data base. i am using C# CF2. I have tried this a number of different ways. Starting with the command builder...
3
by: ianforgroupuse | last post by:
I'm running Vista Business edition on 2005 Virtual PC. Installed SQL Server 2005 Express latest download, with instance of MSSQLSERVER and service accounts running under "NT AUTHORITY\SYSTEM"....
3
by: hsmit.home | last post by:
I spent way too much time on this and I must say, I was a little disgruntled with what has been posted on all the various Xalan C mailing lists. Everyone says there's a solution, but give next to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.