|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Inserting Column With Stored Procedure
Hello:
I want to thank all that reply. I don't know the correct syntax to insert a column in an SQL database table with these parameters. I need it to be a MONEY field and I need a default value of 0(Zero). Can someone point me in the right direction. |
|
#2
|
|||
|
|||
|
Code:
ALTER TABLE myTable ADD myMoneyCol MONEY DEFAULT 0 Not so bad, huh? But you won't be able to pass a parameter in as the name of the column, which means you will have build the SQL Statement into a string and execute it using dynamic SQL. Code:
DECLARE @SQL nvarchar(500) DECLARE @myMoneyCol nvarchar(50) SET @myMoneyCol = 'MoneyColNo1' SET @SQL = 'ALTER TABLE myTable ADD '+@myMoneyCol+' MONEY DEFAULT 0' EXEC(@SQL) Now you're adding security and performance issues. I would doublecheck to make sure adding a column on the fly is the best solution for what you're trying to do. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Inserting Column With Stored Procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|