Click here to Skip to main content
Rate this: bad
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__ at 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!
Smile | :)
Aarti Meswania at 22-Dec-12 5:27am
okay that's nice!
and Welcome! :)
Glad to help you! :)
Aarti Meswania at 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 at 22-Dec-12 5:45am
write query click a play button press f10 for go on
visit link
Aarti Meswania at 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 at 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
0 Sergey Alexandrovich Kryukov 458
1 OriginalGriff 344
2 George Jonsson 233
3 Animesh Datta 130
4 Shemeemsha RA 128
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2014
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