sql - How can I select a row having a BigInt and a DateTime field starting with a specigic value? -
i working on microsoft sql server database , have following problem implement these 2 simple select query.
so have table named mytable has column otherfieldfk of type bigint value of 70016592107.
so example want search record in table have otherfieldfk starting value 70.
i tried use like in way:
select * mytable otherfieldfk = '70%' but doesn't work. think clause works on string, right?
in table have datetime column named datainiziogestione.
i tried same thing:
select * datainiziogestione otherfieldfk = '2016%' but in case doesn't work either.
how can correctly implement these 2 queries?
the first should right, wrote:
select * mytable otherfieldfk = '70%' for second should converted date format in nvarchar (es 121 format aaaa-mm-gg hh:mi:ss.mmm(24h)); in way can make comparison like:
select * mytable convert(nvarchar,datainiziogestione,121) = '2016%' or can directly compare year:
select * mytable year(datainiziogestione) = 2016
Comments
Post a Comment