SQL Server Convert datetime to date without null





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







8















I have a stored procedure like so:



select 
TransactionDate
from
(select
cast(TransactionDate as Date) as TransactionDate
from RetailTransaction) t


However this makes the TransactionDate column of the outer-select nullable, while RetailTransaction.TransactionDate column is not null.



RetailTransaction.TransactionDate definition / design:



enter image description here



Inner Select:



Inner Select



Outer Select:



Outer Select



Even after adding isnull or coalesce SQL Server / SSMS still shows that the outer selects TransactionDate column is still nullable.



select 
TransactionDate
from
(select
isnull(cast(TransactionDate as Date), getdate()) as TransactionDate
from
RetailTransaction) t


Example 2



How do I make the TransactionDate column non nullable?



Note that the database is on Azure with compatibility level 100 (SQL Server 2008).



EDIT:



Adding an isnull on the outer select still make the column nullable to an outer-nested-query:



outer-nested-query










share|improve this question




















  • 1





    What do you mean by the column is still "nullable?"

    – Tim Biegeleisen
    Jan 4 at 4:01













  • @TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

    – Minijack
    Jan 4 at 4:03













  • You control this from your table definition. Can you add that?

    – Tim Biegeleisen
    Jan 4 at 4:04











  • The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

    – Minijack
    Jan 4 at 4:05













  • @TimBiegeleisen Updated the question

    – Minijack
    Jan 4 at 4:14


















8















I have a stored procedure like so:



select 
TransactionDate
from
(select
cast(TransactionDate as Date) as TransactionDate
from RetailTransaction) t


However this makes the TransactionDate column of the outer-select nullable, while RetailTransaction.TransactionDate column is not null.



RetailTransaction.TransactionDate definition / design:



enter image description here



Inner Select:



Inner Select



Outer Select:



Outer Select



Even after adding isnull or coalesce SQL Server / SSMS still shows that the outer selects TransactionDate column is still nullable.



select 
TransactionDate
from
(select
isnull(cast(TransactionDate as Date), getdate()) as TransactionDate
from
RetailTransaction) t


Example 2



How do I make the TransactionDate column non nullable?



Note that the database is on Azure with compatibility level 100 (SQL Server 2008).



EDIT:



Adding an isnull on the outer select still make the column nullable to an outer-nested-query:



outer-nested-query










share|improve this question




















  • 1





    What do you mean by the column is still "nullable?"

    – Tim Biegeleisen
    Jan 4 at 4:01













  • @TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

    – Minijack
    Jan 4 at 4:03













  • You control this from your table definition. Can you add that?

    – Tim Biegeleisen
    Jan 4 at 4:04











  • The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

    – Minijack
    Jan 4 at 4:05













  • @TimBiegeleisen Updated the question

    – Minijack
    Jan 4 at 4:14














8












8








8


1






I have a stored procedure like so:



select 
TransactionDate
from
(select
cast(TransactionDate as Date) as TransactionDate
from RetailTransaction) t


However this makes the TransactionDate column of the outer-select nullable, while RetailTransaction.TransactionDate column is not null.



RetailTransaction.TransactionDate definition / design:



enter image description here



Inner Select:



Inner Select



Outer Select:



Outer Select



Even after adding isnull or coalesce SQL Server / SSMS still shows that the outer selects TransactionDate column is still nullable.



select 
TransactionDate
from
(select
isnull(cast(TransactionDate as Date), getdate()) as TransactionDate
from
RetailTransaction) t


Example 2



How do I make the TransactionDate column non nullable?



Note that the database is on Azure with compatibility level 100 (SQL Server 2008).



EDIT:



Adding an isnull on the outer select still make the column nullable to an outer-nested-query:



outer-nested-query










share|improve this question
















I have a stored procedure like so:



select 
TransactionDate
from
(select
cast(TransactionDate as Date) as TransactionDate
from RetailTransaction) t


However this makes the TransactionDate column of the outer-select nullable, while RetailTransaction.TransactionDate column is not null.



RetailTransaction.TransactionDate definition / design:



enter image description here



Inner Select:



Inner Select



Outer Select:



Outer Select



Even after adding isnull or coalesce SQL Server / SSMS still shows that the outer selects TransactionDate column is still nullable.



select 
TransactionDate
from
(select
isnull(cast(TransactionDate as Date), getdate()) as TransactionDate
from
RetailTransaction) t


Example 2



How do I make the TransactionDate column non nullable?



Note that the database is on Azure with compatibility level 100 (SQL Server 2008).



EDIT:



Adding an isnull on the outer select still make the column nullable to an outer-nested-query:



outer-nested-query







sql-server tsql azure-sql-database ssms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 8 at 1:14







Minijack

















asked Jan 4 at 3:10









MinijackMinijack

299417




299417








  • 1





    What do you mean by the column is still "nullable?"

    – Tim Biegeleisen
    Jan 4 at 4:01













  • @TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

    – Minijack
    Jan 4 at 4:03













  • You control this from your table definition. Can you add that?

    – Tim Biegeleisen
    Jan 4 at 4:04











  • The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

    – Minijack
    Jan 4 at 4:05













  • @TimBiegeleisen Updated the question

    – Minijack
    Jan 4 at 4:14














  • 1





    What do you mean by the column is still "nullable?"

    – Tim Biegeleisen
    Jan 4 at 4:01













  • @TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

    – Minijack
    Jan 4 at 4:03













  • You control this from your table definition. Can you add that?

    – Tim Biegeleisen
    Jan 4 at 4:04











  • The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

    – Minijack
    Jan 4 at 4:05













  • @TimBiegeleisen Updated the question

    – Minijack
    Jan 4 at 4:14








1




1





What do you mean by the column is still "nullable?"

– Tim Biegeleisen
Jan 4 at 4:01







What do you mean by the column is still "nullable?"

– Tim Biegeleisen
Jan 4 at 4:01















@TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

– Minijack
Jan 4 at 4:03







@TimBiegeleisen See the tool tips, the data type of that column is (date, null), when it should be (date, not null). Compare the Inner Select example with the Outer Select example

– Minijack
Jan 4 at 4:03















You control this from your table definition. Can you add that?

– Tim Biegeleisen
Jan 4 at 4:04





You control this from your table definition. Can you add that?

– Tim Biegeleisen
Jan 4 at 4:04













The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

– Minijack
Jan 4 at 4:05







The TransactionDate column in the table RetailTransaction is (datetime, not null). The resulting data set after converting to date is (date, null)

– Minijack
Jan 4 at 4:05















@TimBiegeleisen Updated the question

– Minijack
Jan 4 at 4:14





@TimBiegeleisen Updated the question

– Minijack
Jan 4 at 4:14












3 Answers
3






active

oldest

votes


















1














After reading your comment I did some digging and testing, and even though I couldn't find official documentation about it, you are correct and the casting to date makes the value nullable, even if the datetime is not nullable. I've even tried a different method by using datetimefromparts to create a date data type but that also changes the nullablility of the result.

So the way I see it, you have two options:



The first option is to add a persisted computed column to the table that will hold the date value of the transaction date. It has to be persisted to be non nullable:



ALTER TABLE RetailTransaction
ADD TransactionDateOnly AS CAST(TransactionDate As Date) PERSISTED NOT NULL;


and then your query looks like this:



SELECT TransactionDateOnly as TransactionDate
FROM RetailTransaction


The other option would be to declare a table variable with a non-nullable date column, select the cast results into it, and then select from the table variable:



DECLARE @Target AS TABLE
(
TransactionDate Date NOT NULL
)
INSERT INTO @Target(TransactionDate)
SELECT CAST(TransactionDate as Date)
FROM RetailTransaction) t


And then your select looks like this:



SELECT TransactionDate 
FROM @Target


Both ways will get you a non-nullable date as a result, but I think the persisted computed column option should probably yield better performance on the select, because it doesn't require that extra insert...select.






share|improve this answer


























  • Thank you for your well thought out answer with actual solutions.

    – Minijack
    Jan 15 at 22:21











  • I decided to go with your method of putting my result set into a temporary table and then just returning that.

    – Minijack
    Jan 16 at 4:58











  • Glad to help :-)

    – Zohar Peled
    Jan 16 at 5:26



















3














Yes the reason it is showing Nullable for not nullable column is because you are making your outer select as computed based on isnull condition and others.



In this table Email is not nullable column and now if I give Isnull condition in inner query it will be like this.



enter image description here



Now if I don't give any condition it will be like this.



enter image description here



You can refer to this link as well for detailed explanation.



https://dba.stackexchange.com/questions/114260/why-is-a-not-null-computed-column-considered-nullable-in-a-view






share|improve this answer



















  • 1





    I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

    – ZLK
    Jan 4 at 4:44



















0














The trick is to put the ISNULL on the outer query and add an alias so that you don't lose the name



select 
isnull(TransactionDate, GETDATE()) as TransactionDate
from (
select
Cast(TransactionDate as Date) as TransactionDate
from RetailTransaction
) t


That way SQL will realise that the field cannot be null. This should nicely inform any ORM that this field should not be mapped to a nullable type.






share|improve this answer
























  • Please see updated question. This solution does not work for me.

    – Minijack
    Jan 8 at 1:19











  • @Minijack is it a computed column?

    – Mack
    Jan 8 at 11:46











  • No. TransactionDate is datetime not null

    – Minijack
    Jan 8 at 21:57












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54032669%2fsql-server-convert-datetime-to-date-without-null%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














After reading your comment I did some digging and testing, and even though I couldn't find official documentation about it, you are correct and the casting to date makes the value nullable, even if the datetime is not nullable. I've even tried a different method by using datetimefromparts to create a date data type but that also changes the nullablility of the result.

So the way I see it, you have two options:



The first option is to add a persisted computed column to the table that will hold the date value of the transaction date. It has to be persisted to be non nullable:



ALTER TABLE RetailTransaction
ADD TransactionDateOnly AS CAST(TransactionDate As Date) PERSISTED NOT NULL;


and then your query looks like this:



SELECT TransactionDateOnly as TransactionDate
FROM RetailTransaction


The other option would be to declare a table variable with a non-nullable date column, select the cast results into it, and then select from the table variable:



DECLARE @Target AS TABLE
(
TransactionDate Date NOT NULL
)
INSERT INTO @Target(TransactionDate)
SELECT CAST(TransactionDate as Date)
FROM RetailTransaction) t


And then your select looks like this:



SELECT TransactionDate 
FROM @Target


Both ways will get you a non-nullable date as a result, but I think the persisted computed column option should probably yield better performance on the select, because it doesn't require that extra insert...select.






share|improve this answer


























  • Thank you for your well thought out answer with actual solutions.

    – Minijack
    Jan 15 at 22:21











  • I decided to go with your method of putting my result set into a temporary table and then just returning that.

    – Minijack
    Jan 16 at 4:58











  • Glad to help :-)

    – Zohar Peled
    Jan 16 at 5:26
















1














After reading your comment I did some digging and testing, and even though I couldn't find official documentation about it, you are correct and the casting to date makes the value nullable, even if the datetime is not nullable. I've even tried a different method by using datetimefromparts to create a date data type but that also changes the nullablility of the result.

So the way I see it, you have two options:



The first option is to add a persisted computed column to the table that will hold the date value of the transaction date. It has to be persisted to be non nullable:



ALTER TABLE RetailTransaction
ADD TransactionDateOnly AS CAST(TransactionDate As Date) PERSISTED NOT NULL;


and then your query looks like this:



SELECT TransactionDateOnly as TransactionDate
FROM RetailTransaction


The other option would be to declare a table variable with a non-nullable date column, select the cast results into it, and then select from the table variable:



DECLARE @Target AS TABLE
(
TransactionDate Date NOT NULL
)
INSERT INTO @Target(TransactionDate)
SELECT CAST(TransactionDate as Date)
FROM RetailTransaction) t


And then your select looks like this:



SELECT TransactionDate 
FROM @Target


Both ways will get you a non-nullable date as a result, but I think the persisted computed column option should probably yield better performance on the select, because it doesn't require that extra insert...select.






share|improve this answer


























  • Thank you for your well thought out answer with actual solutions.

    – Minijack
    Jan 15 at 22:21











  • I decided to go with your method of putting my result set into a temporary table and then just returning that.

    – Minijack
    Jan 16 at 4:58











  • Glad to help :-)

    – Zohar Peled
    Jan 16 at 5:26














1












1








1







After reading your comment I did some digging and testing, and even though I couldn't find official documentation about it, you are correct and the casting to date makes the value nullable, even if the datetime is not nullable. I've even tried a different method by using datetimefromparts to create a date data type but that also changes the nullablility of the result.

So the way I see it, you have two options:



The first option is to add a persisted computed column to the table that will hold the date value of the transaction date. It has to be persisted to be non nullable:



ALTER TABLE RetailTransaction
ADD TransactionDateOnly AS CAST(TransactionDate As Date) PERSISTED NOT NULL;


and then your query looks like this:



SELECT TransactionDateOnly as TransactionDate
FROM RetailTransaction


The other option would be to declare a table variable with a non-nullable date column, select the cast results into it, and then select from the table variable:



DECLARE @Target AS TABLE
(
TransactionDate Date NOT NULL
)
INSERT INTO @Target(TransactionDate)
SELECT CAST(TransactionDate as Date)
FROM RetailTransaction) t


And then your select looks like this:



SELECT TransactionDate 
FROM @Target


Both ways will get you a non-nullable date as a result, but I think the persisted computed column option should probably yield better performance on the select, because it doesn't require that extra insert...select.






share|improve this answer















After reading your comment I did some digging and testing, and even though I couldn't find official documentation about it, you are correct and the casting to date makes the value nullable, even if the datetime is not nullable. I've even tried a different method by using datetimefromparts to create a date data type but that also changes the nullablility of the result.

So the way I see it, you have two options:



The first option is to add a persisted computed column to the table that will hold the date value of the transaction date. It has to be persisted to be non nullable:



ALTER TABLE RetailTransaction
ADD TransactionDateOnly AS CAST(TransactionDate As Date) PERSISTED NOT NULL;


and then your query looks like this:



SELECT TransactionDateOnly as TransactionDate
FROM RetailTransaction


The other option would be to declare a table variable with a non-nullable date column, select the cast results into it, and then select from the table variable:



DECLARE @Target AS TABLE
(
TransactionDate Date NOT NULL
)
INSERT INTO @Target(TransactionDate)
SELECT CAST(TransactionDate as Date)
FROM RetailTransaction) t


And then your select looks like this:



SELECT TransactionDate 
FROM @Target


Both ways will get you a non-nullable date as a result, but I think the persisted computed column option should probably yield better performance on the select, because it doesn't require that extra insert...select.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 16 at 4:56

























answered Jan 15 at 7:36









Zohar PeledZohar Peled

57.1k73475




57.1k73475













  • Thank you for your well thought out answer with actual solutions.

    – Minijack
    Jan 15 at 22:21











  • I decided to go with your method of putting my result set into a temporary table and then just returning that.

    – Minijack
    Jan 16 at 4:58











  • Glad to help :-)

    – Zohar Peled
    Jan 16 at 5:26



















  • Thank you for your well thought out answer with actual solutions.

    – Minijack
    Jan 15 at 22:21











  • I decided to go with your method of putting my result set into a temporary table and then just returning that.

    – Minijack
    Jan 16 at 4:58











  • Glad to help :-)

    – Zohar Peled
    Jan 16 at 5:26

















Thank you for your well thought out answer with actual solutions.

– Minijack
Jan 15 at 22:21





Thank you for your well thought out answer with actual solutions.

– Minijack
Jan 15 at 22:21













I decided to go with your method of putting my result set into a temporary table and then just returning that.

– Minijack
Jan 16 at 4:58





I decided to go with your method of putting my result set into a temporary table and then just returning that.

– Minijack
Jan 16 at 4:58













Glad to help :-)

– Zohar Peled
Jan 16 at 5:26





Glad to help :-)

– Zohar Peled
Jan 16 at 5:26













3














Yes the reason it is showing Nullable for not nullable column is because you are making your outer select as computed based on isnull condition and others.



In this table Email is not nullable column and now if I give Isnull condition in inner query it will be like this.



enter image description here



Now if I don't give any condition it will be like this.



enter image description here



You can refer to this link as well for detailed explanation.



https://dba.stackexchange.com/questions/114260/why-is-a-not-null-computed-column-considered-nullable-in-a-view






share|improve this answer



















  • 1





    I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

    – ZLK
    Jan 4 at 4:44
















3














Yes the reason it is showing Nullable for not nullable column is because you are making your outer select as computed based on isnull condition and others.



In this table Email is not nullable column and now if I give Isnull condition in inner query it will be like this.



enter image description here



Now if I don't give any condition it will be like this.



enter image description here



You can refer to this link as well for detailed explanation.



https://dba.stackexchange.com/questions/114260/why-is-a-not-null-computed-column-considered-nullable-in-a-view






share|improve this answer



















  • 1





    I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

    – ZLK
    Jan 4 at 4:44














3












3








3







Yes the reason it is showing Nullable for not nullable column is because you are making your outer select as computed based on isnull condition and others.



In this table Email is not nullable column and now if I give Isnull condition in inner query it will be like this.



enter image description here



Now if I don't give any condition it will be like this.



enter image description here



You can refer to this link as well for detailed explanation.



https://dba.stackexchange.com/questions/114260/why-is-a-not-null-computed-column-considered-nullable-in-a-view






share|improve this answer













Yes the reason it is showing Nullable for not nullable column is because you are making your outer select as computed based on isnull condition and others.



In this table Email is not nullable column and now if I give Isnull condition in inner query it will be like this.



enter image description here



Now if I don't give any condition it will be like this.



enter image description here



You can refer to this link as well for detailed explanation.



https://dba.stackexchange.com/questions/114260/why-is-a-not-null-computed-column-considered-nullable-in-a-view







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 4 at 4:17









AviAvi

841314




841314








  • 1





    I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

    – ZLK
    Jan 4 at 4:44














  • 1





    I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

    – ZLK
    Jan 4 at 4:44








1




1





I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

– ZLK
Jan 4 at 4:44





I don't think this answer is accurate... And the link you've provided explicitly says "An expression that is nullable can be turned into a nonnullable one by specifying ISNULL(check_expression, constant), where the constant is a nonnull value substituted for any null result." so this doesn't address that...

– ZLK
Jan 4 at 4:44











0














The trick is to put the ISNULL on the outer query and add an alias so that you don't lose the name



select 
isnull(TransactionDate, GETDATE()) as TransactionDate
from (
select
Cast(TransactionDate as Date) as TransactionDate
from RetailTransaction
) t


That way SQL will realise that the field cannot be null. This should nicely inform any ORM that this field should not be mapped to a nullable type.






share|improve this answer
























  • Please see updated question. This solution does not work for me.

    – Minijack
    Jan 8 at 1:19











  • @Minijack is it a computed column?

    – Mack
    Jan 8 at 11:46











  • No. TransactionDate is datetime not null

    – Minijack
    Jan 8 at 21:57
















0














The trick is to put the ISNULL on the outer query and add an alias so that you don't lose the name



select 
isnull(TransactionDate, GETDATE()) as TransactionDate
from (
select
Cast(TransactionDate as Date) as TransactionDate
from RetailTransaction
) t


That way SQL will realise that the field cannot be null. This should nicely inform any ORM that this field should not be mapped to a nullable type.






share|improve this answer
























  • Please see updated question. This solution does not work for me.

    – Minijack
    Jan 8 at 1:19











  • @Minijack is it a computed column?

    – Mack
    Jan 8 at 11:46











  • No. TransactionDate is datetime not null

    – Minijack
    Jan 8 at 21:57














0












0








0







The trick is to put the ISNULL on the outer query and add an alias so that you don't lose the name



select 
isnull(TransactionDate, GETDATE()) as TransactionDate
from (
select
Cast(TransactionDate as Date) as TransactionDate
from RetailTransaction
) t


That way SQL will realise that the field cannot be null. This should nicely inform any ORM that this field should not be mapped to a nullable type.






share|improve this answer













The trick is to put the ISNULL on the outer query and add an alias so that you don't lose the name



select 
isnull(TransactionDate, GETDATE()) as TransactionDate
from (
select
Cast(TransactionDate as Date) as TransactionDate
from RetailTransaction
) t


That way SQL will realise that the field cannot be null. This should nicely inform any ORM that this field should not be mapped to a nullable type.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 4 at 10:34









MackMack

2,30012142




2,30012142













  • Please see updated question. This solution does not work for me.

    – Minijack
    Jan 8 at 1:19











  • @Minijack is it a computed column?

    – Mack
    Jan 8 at 11:46











  • No. TransactionDate is datetime not null

    – Minijack
    Jan 8 at 21:57



















  • Please see updated question. This solution does not work for me.

    – Minijack
    Jan 8 at 1:19











  • @Minijack is it a computed column?

    – Mack
    Jan 8 at 11:46











  • No. TransactionDate is datetime not null

    – Minijack
    Jan 8 at 21:57

















Please see updated question. This solution does not work for me.

– Minijack
Jan 8 at 1:19





Please see updated question. This solution does not work for me.

– Minijack
Jan 8 at 1:19













@Minijack is it a computed column?

– Mack
Jan 8 at 11:46





@Minijack is it a computed column?

– Mack
Jan 8 at 11:46













No. TransactionDate is datetime not null

– Minijack
Jan 8 at 21:57





No. TransactionDate is datetime not null

– Minijack
Jan 8 at 21:57


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54032669%2fsql-server-convert-datetime-to-date-without-null%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas