Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Too much validation from SQL Server
Message
 
To
26/02/2010 01:55:09
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01451147
Message ID:
01451149
Views:
57
>I have a weird situation here. Here is the script:
>
>
>ALTER TABLE [Advertis] ADD [AddUserTemporary] int
>UPDATE [Advertis] SET [AddUserTemporary]=AddUser
>
>
>SQL Server is too smart and doesn't want to execute this script because the second line contains a field which does not exist. Well, I know that because I want to create it in the first line. But, because it validates the entire script before starting, I cannot execute this.
>
>Any idea?

Just put them in two separate batches:
ALTER TABLE [Advertis] ADD [AddUserTemporary] int
GO
UPDATE [Advertis] SET [AddUserTemporary]=AddUser
or if you have to do this from an application:
EXEC sp_executesql N'ALTER TABLE [Advertis] ADD [AddUserTemporary] int'
EXEC sp_executesql N'UPDATE [Advertis] SET [AddUserTemporary]=AddUser'
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform