Professional Web Applications Themes

Simple syntax help - Microsoft SQL / MS SQL Server

Newbie Q- someone suggested I use drop constraint [DF__Products__Price__7C4F7684] to remove a constraint, but I got an 'incorrect syntax near Constraint' error. The reason I need to do this is because I tried ALTER TABLE Products ALTER COLUMN Price Money but got the constraint mentioned above. (What I want to do is change the type of a column in a table from Float to Money.) Please complete this picture for me: DROP CONSTRAINT [DF__Products__Price__7C4F7684] <<Syntax Error then ALTER TABLE Products ALTER COLUMN Price Money then < replace the constraint ?> Thanks for any help Justin Dutoit...

  1. #1

    Default Simple syntax help

    Newbie Q- someone suggested I use

    drop constraint [DF__Products__Price__7C4F7684]

    to remove a constraint, but I got an 'incorrect syntax near Constraint'
    error.
    The reason I need to do this is because I tried
    ALTER TABLE Products ALTER COLUMN Price Money
    but got the constraint mentioned above.
    (What I want to do is change the type of a column in a table from Float to
    Money.)

    Please complete this picture for me:

    DROP CONSTRAINT [DF__Products__Price__7C4F7684] <<Syntax Error

    then
    ALTER TABLE Products ALTER COLUMN Price Money
    then
    < replace the constraint ?>

    Thanks for any help

    Justin Dutoit





    Justin Guest

  2. #2

    Default Re: Simple syntax help

    try

    ALTER TABLE Products DROP CONSTRAINT [DF__Products__Price__7C4F7684]
    go
    ALTER TABLE Products ALTER COLUMN Price Money
    go
    here you need to define your constraint again.

    HTH

    Falik

    "Justin Dutoit" <com> wrote in message
    news:phx.gbl... 


    Falik Guest

  3. #3

    Default Re: Simple syntax help

    To add to Falik's response, consider specifying an explicit constraint
    name when you add the constraint. This makes subsequent schema
    modifications easier. For example:

    ALTER TABLE Products
    ADD CONSTRAINT DF_Products_Price
    DEFAULT (0) FOR Price

    --
    Hope this helps.

    Dan Guzman
    SQL Server MVP

    -----------------------
    SQL FAQ links (courtesy Neil Pike):

    http://www.ntfaq.com/Articles/Index.cfm?DepartmentID=800
    http://www.sqlserverfaq.com
    http://www.mssqlserver.com/faq
    -----------------------

    "Justin Dutoit" <com> wrote in message
    news:phx.gbl... 
    Constraint' 
    Float to 


    Dan Guest

Similar Threads

  1. Simple syntax question
    By Hompf in forum MySQL
    Replies: 2
    Last Post: March 10th, 09:32 PM
  2. dummy here needs simple MySQL syntax help
    By Lossed in forum Coldfusion Database Access
    Replies: 1
    Last Post: February 10th, 03:03 AM
  3. simple syntax issue?
    By geo in forum Adobe Flash, Flex & Director
    Replies: 0
    Last Post: February 2nd, 10:47 AM
  4. Hopefully simple syntax issue with forms
    By bill_doe in forum Macromedia ColdFusion
    Replies: 11
    Last Post: June 16th, 06:10 PM
  5. Simple PHP Headers Syntax Question
    By jip in forum Dreamweaver AppDev
    Replies: 1
    Last Post: April 8th, 04:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139