Tuesday, 6 April 2021

MSSQL - How to increase length of existing varchar

Watch this example on YouTube


ALter Table Test01
Alter Column RealName Varchar(100) 

MSSQL - Rename column in table

Watch this example on YouTube


exec sp_rename 'TableName.CurrentColumnName', 'NewColumnName', 'COLUMN' 

MSSQL - Rename table

 

Watch this example on YouTube

 

 

 exec sp_rename 'CurrentTableName' , 'NewTableName'

Monday, 5 April 2021

MSSQL - Fix Error - Column names in each table must be unique. Column name 'IsValid' in table 'Test1' is specified more than once.

 Watch this example on YouTube


To fix it replace

 Alter Table Test1
Add IsValid bit not null Default 0

with  


IF COL_LENGTH('dbo.Test1', 'IsValid') Is Null
Begin

Alter Table Test1
Add IsValid bit not null Default 0
End

MSSQL - Add column only if it doesn't exist

 Watch this example on YouTube


 

IF COL_LENGTH('dbo.Test3', 'IsValid') is null
Begin
    Alter Table Test3 Add IsValid bit not null default 0
End

Select * from Test3

Thursday, 1 April 2021

MVC5 - Add modal (popup dialog)

 Watch this example on YouTube

 1. View

@{
    ViewBag.Title = "Home Page";
}
<div class="AddPopUp">
    @Html.Label("Add pop up")
</div>
<div class="modal fade" id="MyPopUp" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                here are going your controls etc
            </div>
        </div>
    </div>
</div>

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $(".AddPopUp").click(function (e) {
                $('#MyPopUp').modal('show');
            });
        });
    </script>
    }


2. CSS

.modal-content{
    height: 500px;
    width: 700px;
}