Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

select into casting not null question

$
0
0

OK here's a little thingy I just ran into, minor but curious.

I'm doing a big select into with a union, and I want to mark the source of rows with code like:

selectcast(0 asbit) as src, a, b, c, d, ...unionallcast(1 asbit) as src, a, b, c, d, ...
into dbo.myfoo;

Just to be extra careful, I wanted to have the src field "not null", but the cast operator doesn't seem to like it.

selectcast(0 asbitnotnull) as myzero, -- invalid syntaxcast(1 asbitnotnull) as myone -- invalid syntaxinto dbo.zz_foo;

(also, too bad there's no way to specify a constant as bit!)

Any ideas?

Thanks.

Josh

 



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>