Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi to all!

i create procedure in which i have two arguments

id and name

in table i have three fields
id , name, iname

where i will pass id and name to procedure and the
iname should be id+name

e.g.
id=23
name=asd
iname=asd123
Posted

i think you want to insert Data
for that try this

insert into TableName values(@id,@Name,cast(@id as varchar(50))+@Name)
 
Share this answer
 
Comments
kami124 4-Aug-11 2:22am    
thanks
kami124 4-Aug-11 2:55am    
here is little problem
e.g id= 123
name=asdf
then
iname=123asdf
but i want like this
asdf123
how to do this
Mahendra.p25 4-Aug-11 6:21am    
insert into TableName values(@id,@Name,@Name+cast(@id as varchar(50)))
You can use +
SQL
Select id+name from tablename
update tablename set iname = id+name


If id is numeric then you should use Cast or Convert.
SQL
CONVERT(varchar, id) + name
 
Share this answer
 
Assuming your ID is INT, you can do it this way.
SQL
SELECT id, name, name + CONVERT(VARCHAR(10), id) AS iname FROM yourTable
 
Share this answer
 
Read more about stored procedures here[^].
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900