House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Search sql

February 09, 2010

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28             

Home /  Groups /  SQL

Alter column problem

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Silly me I thought this would be a simple thing to do.
Bruce, Rodney S Mr CTR USA AMC
08/30/07 05:03 P
Try this:
Maya Tulchinsky
09/02/07 07:58 P
Thanks for suggection, but it didn't work either.
Bruce, Rodney S Mr CTR USA AMC
09/04/07 12:05 P
Yes, That worked
Bruce, Rodney S Mr CTR USA AMC
09/04/07 01:39 P
Here is url:
Maya Tulchinsky
09/04/07 02:14 P
Thanks for the help
Bruce, Rodney S Mr CTR USA AMC
09/04/07 02:21 P
Sorry, wrong url. Here is a correct one:
Maya Tulchinsky
09/04/07 02:19 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bruce, Rodney S Mr CTR USA AMC
08/30/2007 05:03 PM

Silly me I thought this would be a simple thing to do. I want to set defaults for some fields using a stored procedure. My testing SP looks like: ------------SP Code------------------------ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE SPTemp    AS BEGIN ALTER TABLE [dbo].[Contact_tbl] ALTER COLUMN FirstName DEFAULT 'dddddd' END GO ---------------------------------------------- I have tried veriations with and without [] around field name, with and without SET These are the errors I am getting: Msg 156, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'DEFAULT'. Using SET: ALTER TABLE [dbo].[Contact_tbl] ALTER COLUMN [FirstName] SET DEFAULT 'dddddd' Msg 156, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'SET'. Example from http://technet.microsoft.com/en-us/library/ms174123.aspx ALTER TABLE MyCustomers ALTER COLUMN CompanyName SET DEFAULT 'A. Datum Corporation' Thanks for any help Rodney

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
08/30/2007 06:03 PM

Aren't the [brackets] just for when names have spaces or are keywords? Anyway, the syntax looks okay against that example... maybe try something like this: ALTER TABLE Contact_tbl MODIFY FirstName VARCHAR(50) DEFAULT 'dddddd' ? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bruce, Rodney S Mr CTR USA AMC
08/30/2007 06:16 PM

That's my understanding of [] also, but I don't think they hurt (in most cases) if used when not needed And I was tring any veriation I could think of. Nope it don't like Modify either. ALTER TABLE [dbo].[Contact_tbl] MODIFY [FirstName] SET DEFAULT 'dddddd' GETS: Msg 102, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName'. ALTER TABLE [dbo].[Contact_tbl] MODIFY FirstName SET DEFAULT 'dddddd' GETS: Msg 102, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'MODIFY'. So there the [] make a difference, just not sure what or why. Thanks for the suggestion. Rodney Aren't the [brackets] just for when names have spaces or are keywords? Anyway, the syntax looks okay against that example... maybe try something like this: ALTER TABLE Contact_tbl MODIFY FirstName VARCHAR(50) DEFAULT 'dddddd' ?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Maya Tulchinsky
09/02/2007 07:58 PM

Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya "Bruce, Rodney S Mr CTR USA AMC" <rodney.s.bruce1@us.army.mil> wrote: Silly me I thought this would be a simple thing to do. I want to set defaults for some fields using a stored procedure. My testing SP looks like: ------------SP Code------------------------ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE SPTemp AS BEGIN ALTER TABLE [dbo].[Contact_tbl] ALTER COLUMN FirstName DEFAULT 'dddddd' END GO ---------------------------------------------- I have tried veriations with and without [] around field name, with and without SET These are the errors I am getting: Msg 156, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'DEFAULT'. Using SET: ALTER TABLE [dbo].[Contact_tbl] ALTER COLUMN [FirstName] SET DEFAULT 'dddddd' Msg 156, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'SET'. Example from http://technet.microsoft.com/en-us/library/ms174123.aspx ALTER TABLE MyCustomers ALTER COLUMN CompanyName SET DEFAULT 'A. Datum Corporation' Thanks for any help Rodney

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bruce, Rodney S Mr CTR USA AMC
09/04/2007 12:05 PM

Thanks for suggection, but it didn't work either. Removing COLUMN changed the error message to: Msg 170, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName '. The ";" doesn't seem to make a difference either way. Thanks Rodney Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Maya Tulchinsky
09/04/2007 01:23 PM

ALTER TABLE Contact_tbl add default 'dddddd' for FirstName Tested and it should work if you currently don't have any defaults for this column. Maya "Bruce, Rodney S Mr CTR USA AMC" <rodney.s.bruce1@us.army.mil> wrote:   Thanks for suggection, but it didn't work either. Removing COLUMN changed the error message to: Msg 170, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName '. The ";" doesn't seem to make a difference either way. Thanks Rodney Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bruce, Rodney S Mr CTR USA AMC
09/04/2007 01:39 PM

Yes,  That worked Were did you find the syntex? I always seem to find: ALTER [COLUMN] column_name SET default_expr alters the default value for the column. As examples Thanks Rodney ALTER TABLE Contact_tbl add default 'dddddd' for FirstName Tested and it should work if you currently don't have any defaults for this column. Maya "Bruce, Rodney S Mr CTR USA AMC" <rodney.s.bruce1@us.army.mil> wrote:   Thanks for suggection, but it didn't work either. Removing COLUMN changed the error message to: Msg 170, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName '. The ";" doesn't seem to make a difference either way. Thanks Rodney Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Maya Tulchinsky
09/04/2007 02:14 PM

Here is url: http://msdn2.microsoft.com/en-US/library/aa237859(sql.80).aspx Maya "Bruce, Rodney S Mr CTR USA AMC" <rodney.s.bruce1@us.army.mil> wrote: Yes,   That worked Were did you find the syntex? I always seem to find: ALTER [COLUMN] column_name SET default_expr alters the default value for the column. As examples Thanks Rodney ALTER TABLE Contact_tbl add default 'dddddd' for FirstName Tested and it should work if you currently don't have any defaults for this column. Maya "Bruce, Rodney S Mr CTR USA AMC"  wrote:   Thanks for suggection, but it didn't work either. Removing COLUMN changed the error message to: Msg 170, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName '. The ";" doesn't seem to make a difference either way. Thanks Rodney Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bruce, Rodney S Mr CTR USA AMC
09/04/2007 02:21 PM

Thanks for the help Here is url: http://msdn2.microsoft.com/en-US/library/aa237859(sql.80).aspx Maya

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Maya Tulchinsky
09/04/2007 02:19 PM

Sorry, wrong url.  Here is a correct one: http://www.akadia.com/services/sqlsrv_table_auditing.html Maya "Bruce, Rodney S Mr CTR USA AMC" <rodney.s.bruce1@us.army.mil> wrote: Yes,   That worked Were did you find the syntex? I always seem to find: ALTER [COLUMN] column_name SET default_expr alters the default value for the column. As examples Thanks Rodney ALTER TABLE Contact_tbl add default 'dddddd' for FirstName Tested and it should work if you currently don't have any defaults for this column. Maya "Bruce, Rodney S Mr CTR USA AMC"  wrote:   Thanks for suggection, but it didn't work either. Removing COLUMN changed the error message to: Msg 170, Level 15, State 1, Procedure SPTemp, Line 8 Incorrect syntax near the keyword 'FirstName '. The ";" doesn't seem to make a difference either way. Thanks Rodney Try this: ALTER TABLE  [dbo].[Contact_tbl] ALTER FirstName SET DEFAULT 'dddddd'; Hope this helps, Maya


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists