Log in
::
Register
::
Not logged in
Search:
Home
Articles
Editorials
Forums
Scripts
Blogs
QotD
Books
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Advertise
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Alter Table within a Stored Procedure
Alter Table within a Stored Procedure
Rate Topic
Display Mode
Topic Options
Author
Message
madala
madala
Posted Monday, May 19, 2008 7:47 AM
Grasshopper
Group: General Forum Members
Last Login: Monday, June 29, 2009 7:36 AM
Points: 13,
Visits: 234
I have the following Stored Procedure. When I run it, it executes without errors, but it does not alter the table to add the new column? Any ideas?
CREATE PROCEDURE sp_MyStoredProcedure AS
BEGIN
exec sp_executesql 'alter table MyTable add dte datetime null'
END
Post #502806
Steve Jones - Editor
Steve Jones - Editor
Posted Monday, May 19, 2008 8:46 AM
SSChampion
Group: Administrators
Last Login: Today @ 11:21 AM
Points: 19,448,
Visits: 5,033
First I think you need
... sp_executeSQL N' alter table ...'
And it works for me, SS2K5, dev, SP2.
Columns added to table.
Do you have permissions to add columns?
Post #502846
Grant Fritchey
Grant Fritchey
Posted Monday, May 19, 2008 10:55 AM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 7:20 PM
Points: 5,822,
Visits: 10,705
It should work. Are you sure you're in the right database? Are you looking through Management Studio? You might need to refresh in order to see the change.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of
SQL Server 2008 Query Performance Tuning Distilled
For better & quicker help read:
How to Post Performance Problems
Post #502975
madala
madala
Posted Monday, May 19, 2008 10:43 PM
Grasshopper
Group: General Forum Members
Last Login: Monday, June 29, 2009 7:36 AM
Points: 13,
Visits: 234
Thanks Steve,
Indeed the N is needed before the string otherwise you get the following error:
Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar'
Post #503292
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
may
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2009 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use