SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 After Keyword is not working in sql
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

suvis10
Starting Member

1 Posts

Posted - 12/27/2011 :  01:38:23  Show Profile  Reply with Quote
Hi


I am using sql 2005 .i want to create a new field using "after"
i used below query but it says

error:incorrect syntax near after

alter table sessions add speakercredential nvarchar(max) after SpeakerTitle

can u pls help me

khtan
In (Som, Ni, Yak)

Singapore
17586 Posts

Posted - 12/27/2011 :  01:48:27  Show Profile  Reply with Quote
You can't do that in SQL Server.

Order of column in a table is irrelevant. You can specify the column order that you need in the SELECT statement.






KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 12/27/2011 :  02:24:57  Show Profile  Reply with Quote
quote:
Originally posted by suvis10

Hi


I am using sql 2005 .i want to create a new field using "after"
i used below query but it says

error:incorrect syntax near after

alter table sessions add speakercredential nvarchar(max) after SpeakerTitle

can u pls help me



the column position in a table is fixed and is available from ORDINAL_POSITION column of INFORMATION_SCHEMA.COLUMNS view.
Once created you cant change it.
And as Tan points out its irrelevant as you can always return the columns in the order you want by specifying it in select list



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

Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 12/27/2011 :  08:02:52  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
quote:
Originally posted by suvis10

Hi


I am using sql 2005 .i want to create a new field using "after"
i used below query but it says

error:incorrect syntax near after

alter table sessions add speakercredential nvarchar(max) after SpeakerTitle

can u pls help me



You can create a view that has columns with the preferred order. If you need it in a table, use SSMS design option to do this

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000