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
 Urgent - Please help

Author  Topic 

skas502
Starting Member

6 Posts

Posted - 2007-11-05 : 20:58:19
We have two instances of SQL Server 2005 running. One is production and other one is Dev. I have inserted two new fields into an existing table in Dev instance. Now I want to generate a script which can be run in the production environment so that same fields can be added in the production table too.

Urgent reply from anyone would be highly appreciated.

Thanks

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-11-05 : 21:16:55
You can generate script for tale in dev instance in ssms, modify the script then run the script to add columns in prod instance.
Go to Top of Page

skas502
Starting Member

6 Posts

Posted - 2007-11-05 : 21:23:43
I am new to the SQL Server. Can anyone please give me example of script. Thanks
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-11-05 : 21:30:59
Take look at 'generate script' in books online.
Go to Top of Page

skas502
Starting Member

6 Posts

Posted - 2007-11-05 : 23:29:03
After some research I generated following script. Now my question here is this script does not identify the database name. If there are several databases are running on production server how will this script identify the database name? Is there any option to include database name in the following script? Thanks

BEGIN TRANSACTION
SET QUOTED_IDENTIFIER ON
SET ARITHABORT ON
SET NUMERIC_ROUNDABORT OFF
SET CONCAT_NULL_YIELDS_NULL ON
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
COMMIT
BEGIN TRANSACTION
GO
ALTER TABLE dbo.Table1 ADD
NewColumn nvarchar(250) NULL
GO
COMMIT
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-05 : 23:32:22
it will run in current database context. Add "use <database_name> to change the current database context




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

skas502
Starting Member

6 Posts

Posted - 2007-11-06 : 13:07:14
I get this error on ASP page after adding the columns into my table with script. If I add columns manually
into the table ASP pages work fine.


Error Type:
Microsoft VBScript runtime (0x800A0009)
Subscript out of range: 'Index'
/GSCOM/GroupShareSecure/newClasses/clsBaseCollection.asp, line 23
Go to Top of Page
   

- Advertisement -