how to edit coloumn or add text in column via stored procedures
-
Thursday, March 01, 2012 12:17 PM
Hi
how i can get the text of specific column and then add something to insert again using stored procedure
Thanks
All Replies
-
Thursday, March 01, 2012 12:51 PMAnswerer
I am not sure that understood you.What does it mean "get the text of specific column"? A data or a column name?
Can you provide an example?
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
-
Thursday, March 01, 2012 1:02 PM
I am not sure that understood you.What does it mean "get the text of specific column"? A data or a column name?
Can you provide an example?
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
yea , im talking about data
i want to edit the column dataof database using stored procedure. how i can edit it ? 1sst getting it stored procedure then editing it or adding something to that data .
-
Thursday, March 01, 2012 1:20 PM
yea , im talking about data
i want to edit the column dataof database using stored procedure. how i can edit it ? 1sst getting it stored procedure then editing it or adding something to that data .
ShanKhan,
Try
-- CREATE A TABLE CREATE TABLE EMP(ID INT,EMPNAME VARCHAR(10)) -- INSERT A RECORD INSERT INTO EMP VALUES(1,'SHANKHAN') -- CREATE A PROCEDURE CREATE PROCEDURE UPDATEEMP @ID INT,@EMPNAME VARCHAR(10) AS BEGIN UPDATE EMP SET EMPNAME=@EMPNAME WHERE ID=@ID END -- EXECUTE PROCEDURE EXEC UPDATEEMP 1,'NEWNAME' -- VERIFY YOUR TABLE SELECT * FROM EMP
Thanks
Manish
Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful. -
Thursday, March 01, 2012 1:25 PM
yea , im talking about data
i want to edit the column dataof database using stored procedure. how i can edit it ? 1sst getting it stored procedure then editing it or adding something to that data .
ShanKhan,
Try
-- CREATE A TABLE CREATE TABLE EMP(ID INT,EMPNAME VARCHAR(10)) -- INSERT A RECORD INSERT INTO EMP VALUES(1,'SHANKHAN') -- CREATE A PROCEDURE CREATE PROCEDURE UPDATEEMP @ID INT,@EMPNAME VARCHAR(10) AS BEGIN UPDATE EMP SET EMPNAME=@EMPNAME WHERE ID=@ID END -- EXECUTE PROCEDURE EXEC UPDATEEMP 1,'NEWNAME' -- VERIFY YOUR TABLE SELECT * FROM EMP
Thanks
Manish
Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.it will overwrite the EMPNAME , can you please show me that
there is 'BAC' in EMPNAME , i want to insert 'ZZZ'
it should become 'BAC;ZZZ' in that column
thanks
-
Thursday, March 01, 2012 1:39 PM
it will overwrite the EMPNAME , can you please show me that
there is 'BAC' in EMPNAME , i want to insert 'ZZZ'
it should become 'BAC;ZZZ' in that column
thanks
Try,
CREATE PROCEDURE UPDATEEMP @ID INT,@EMPNAME VARCHAR(10) AS BEGIN UPDATE EMP SET EMPNAME=EMPNAME+';'+@EMPNAME WHERE ID=@ID END
But if you are adding the values in your column like this you have to make sure that your column length shall be capable to hold those values.Thanks
Manish
Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.- Marked As Answer by Shan Khan Thursday, March 01, 2012 1:54 PM
-
Friday, March 02, 2012 7:27 AM
thanks , can you please show me also how i can handle a exception on updating if the data size is full.
it will overwrite the EMPNAME , can you please show me that
there is 'BAC' in EMPNAME , i want to insert 'ZZZ'
it should become 'BAC;ZZZ' in that column
thanks
Try,
CREATE PROCEDURE UPDATEEMP @ID INT,@EMPNAME VARCHAR(10) AS BEGIN UPDATE EMP SET EMPNAME=EMPNAME+';'+@EMPNAME WHERE ID=@ID END
But if you are adding the values in your column like this you have to make sure that your column length shall be capable to hold those values.
Thanks
Manish
Please use Mark as Answer if my post solved your problem and use Vote As Helpful if a post was useful.- Edited by Shan Khan Friday, March 02, 2012 7:27 AM

