Skip to content

ErcanOPAK.com

  • ASP.Net WebForms
  • ASP.Net MVC
  • C#
  • SQL
  • MySQL
  • PHP
  • Devexpress
  • Reportviewer
  • About
SQL

Add Default Value in SQL Server

- 03.06.18 | 03.06.18 - ErcanOPAK

If there is no default value for the column then you can use this query:

ALTER TABLE MyTable
ADD CONSTRAINT df_MyTable_MyColumn DEFAULT 0 FOR MyColumn


But if there is a default value then first you must drop it:

ALTER TABLE MyTable
DROP CONSTRAINT df_MyTable_MyColumn

Related posts:

How to clean Query and Execution Plan Cache for Efficient Testing in MS SQL
How to add default value for Entity Framework migrations for DateTime and Bool
How to find records based on CAPITAL and small letters in SQL Query?
Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql st...
Post Views: 204

Post navigation

Search text in all stored procedures in SQL Server
Add RowNumber to Gridview

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

November 2023
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Oct    

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (692)
  • Get the User Name and Domain Name from an Email Address in SQL (690)
  • How to select distinct rows in a datatable in C# (548)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (336)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (332)
  • Find numbers with more than two decimal places in SQL (320)
  • Confirm before process with ASPxButton in Devexpress (313)
  • ASPxGridView – Disable CheckBox based on condition in GridViewCommandColumn (288)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github
  • How to display HTML components on the same line in CSS
  • How to insert results of a stored procedure into a temporary table
  • How to remove all non alphanumeric characters from a string in C#
  • How to get the Xth Day of the Week of the Year in C#
  • How to get formatted JSON in C#

Most Viewed Posts

  • Get the First and Last Word from a String or Sentence in SQL (692)
  • Get the User Name and Domain Name from an Email Address in SQL (690)
  • How to select distinct rows in a datatable in C# (548)
  • Add Constraint to SQL Table to ensure email contains @ (446)
  • Average of all values in a column that are not zero in SQL (366)

Recent Posts

  • How to convert JPG or PNG to WebP in batch or single mode
  • How to get the first and the last day of previous month in SQL Server
  • Not Null check on LEFT function with T-SQL
  • NICE 100 YILLARA TÜRKİYEM
  • How to delete all commit history in github

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter

© 2023 ErcanOPAK.com

Proudly powered by WordPress | Theme: Xblog Plus by wpthemespace.com