Prepare for your Next Interview
This is a discussion on stored procedures within the SQL forums, part of the Databases category; Hi all i have a table called dbo.priorites which contains 2 columns _codepriorite varchar (20) primary key _priorite varchar (50) null so i was asked to change _codepriorite varchar (...
|
|||
|
stored procedures
Hi all
i have a table called dbo.priorites which contains 2 columns _codepriorite varchar (20) primary key _priorite varchar (50) null so i was asked to change _codepriorite varchar (20) into _codepriorite int(4) it worked with this script alter table dbo.priorites drop constraint pk_priorites go alter table dbo.priorites drop column _codepriorite go alter table dbo.priorites add _codepriorite int identity go alter table dbo.priorites add primary key (_codepriorite) go i wanna use this script from the compiler , like with stored procedures... I wanna call this script from the software im working with... Any ideas on how to do it? ill be thankful for some help... Last edited by ronaldrahme : 07-01-2008 at 08:47 AM. |
| Sponsored Links |
|
|||
|
Re: stored procedures
Do you want to write general script or script specific to this table only?
If it is a general script pass table name and column name as parameter. You can't execute DDL statements directly in procedures. Use EXECUTE IMMEDIATE to execute above statemetns in procedure. |
| The Following User Says Thank You to krishnaindia2007 For This Useful Post: | ||
|
|||
|
Re: stored procedures
Thnks krishna for your help
i made a stored proceduren i checked the syntax, it was okay: create procedure sp_priorites as execute immediate alter table dbo.priorites drop constraint pk_priorites go execute immediate alter table dbo.priorites drop column _codepriorite go execute immediate alter table dbo.priorites add _codepriorite int identity go execute immediate alter table dbo.priorites add primary key (_codepriorite) go do you think it might work this way? |
|
|||
|
Re: stored procedures
Here is the example
Code:
create or replace procedure test_proc as string varchar2(100); begin string := ' alter table test_data add constraint test_data_pk primary key (x)'; execute immediate string; end; / |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Procedures Reg. | babi_geek | Oracle | 1 | 06-04-2008 07:59 AM |
| Can we use procedures within Views | Subashini.Ramasamy | SQL | 7 | 02-12-2008 10:08 AM |
| Stored Procedures in Reports | malathim | Data Warehousing | 0 | 02-09-2008 05:41 AM |
| Test cases for testing databases & stored procedures | rafina | Test Cases | 2 | 08-16-2007 12:37 PM |
| execute MS-SQL Stored procedures from QTP | Geek_Guest | QTP | 0 | 06-09-2007 01:53 PM |