Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Create or Alter Table /Procedure

Author  Topic 

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-05-15 : 06:04:41
Is there any way in MSSQL to use "create or alter Table" command like in Oracle? my DBA is angry when I give him a long list of sql script and halfway, the sql script stop because the table being alter is not created in the database. I am annoyed because I need to manually check one by one all the tables and store procedures for differences

For store procedure, I can use if store procedure exists and drop them and create the store procedures every time. But for table with data, I could not do that without impacting the data. :(

If anyone knows of any walkaround for "create or alter table" command in MSSQL 2005, kindly let me know. Thank you very much and have a wonderful day!

P.S. I have requested for this feature from Microsoft for sometime, but sad to say it will not be out in MSSQL 2008 as well

malaytech2008
Yak Posting Veteran

95 Posts

Posted - 2009-05-15 : 06:10:19
Before creating the table just check...

if not exists(select 1 from sys.objects where name='table_name')
Begin
Create table ....
......
......
End

Malay
Go to Top of Page

EugeneLim11
Posting Yak Master

167 Posts

Posted - 2009-05-15 : 06:13:11
oh.. excellent idea! thank you.

Else will alter table :)

regards,


check out my blog at http://www.aquariumlore.blogspot.com
Go to Top of Page
   

- Advertisement -