Click here to Skip to main content
12,504,462 members (55,059 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-Server
hi frnds!!

i create store procedure for inset data into table.

@No=select max(no) from reg_table //select maximum no from other table
insert into table values('1','101',@No);

i want to do this but @no not store result of query.

how can fetch NO and insert it into table???
Posted 21-Dec-12 20:28pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

@No=select max(no) from reg_table
select @No = max(no) from reg_table
That should resolve your issue.
__TR__ 22-Dec-12 6:15am
You're welcome.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

this will also help
select @No = max(no) from reg_table
insert into table values('1','101',@No);
insert into table
(Select max(no) from reg_table)
Happy Coding!
Aarti Meswania 22-Dec-12 5:27am
okay that's nice!
and Welcome! :)
Glad to help you! :)
Aarti Meswania 22-Dec-12 5:38am
you can do so if you are using sql 2008 but nope if it's lower version of sql
Aarti Meswania 22-Dec-12 5:45am
write query click a play button press f10 for go on
visit link
Aarti Meswania 22-Dec-12 6:01am
welcome! :) same as visual studio F11 and F10 is useful and you can put debug point using F9
Aarti Meswania 22-Dec-12 8:04am
okay it's you! I will

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100