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
 How to add a column to table

Author  Topic 

Adam West
Constraint Violating Yak Guru

261 Posts

Posted - 2010-08-25 : 09:49:40
HI We have an app that has a link for other reports. But, only some customers have rights to such reports. Instead of hard coding in the code, I would like to add a column to this table:
SELECT TOP 1000 [UserReportID]
,[UserName]
,[ReportCode]
FROM [SECURITYDB].[dbo].[UserReports]
a small table. I can add a column that would be a switch to indicate whether to have the link show for 'Reports'

I am not sure how to add a column in a production setting, would this have any affect, etc.

Thank you,
Adam

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-25 : 09:54:17
you can add column using ALTER TABLE [SECURITYDB].[dbo].[UserReports] ADD <column name> <datatype>... command

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-08-25 : 10:32:20
Adding a column can have some bad effects. If that table is populated by
INSERT INTO destination SELECT * from source then adding a new column will break that query. Or if some App is doing a select * from that table it might break the app.



Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-08-26 : 09:44:17
That is a perfect example of why you should never use "select *" for anything, ever.

- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page
   

- Advertisement -