为什么我的嵌套SQL SELECT INTO语句不起作用?

时间:2015-06-03 05:07:45

标签: sql sql-server database vb.net

基本的SELECT INTO语句有效,但我需要在另一个表中获取TransactionNumbers,其中该表中的日期等于我设置的任何内容,因此新表不会获得所有TransactionNumbers。这该怎么做?谢谢你的帮助!

query = select * into [bos_primary_db2].dbo.[TenderEntry] from
[bos_primary_db].dbo.[TenderEntry] 
where [TenderEntry].TransactionNumber in 
          (select TransactionNumber 
          from [bos_primary_db.dbo].[Transaction] 
          where [Transaction].Date >= '2012-2-2' 
                          and [Transaction].Date < '2012-2-3')

3 个答案:

答案 0 :(得分:0)

你可以试试这个:

[Transaction].Date BETWEEN '2012-02-02' and '2012-02-03'

答案 1 :(得分:0)

您必须将String转换为日期:

$( "p" ).on( "myCustomEvent", function( event, myName ) {

  $( this ).text( myName + ", hi there!" );

  $( "span" )
    .stop()
    .css( "opacity", 1 )
    .text( "myName = " + myName )
    .fadeIn( 30 )
    .fadeOut( 5000 );
});

$( "button" ).click(function () {
  $( "p" ).trigger( "myCustomEvent", [ "John" ] );
  //alert(1);
});

var loop = setInterval(function(){
    $('.box').append('<button>Trigger custom event</button>');

},1000);

window.setTimeout(function(){ clearInterval(loop); },2000);

答案 2 :(得分:0)

试试这个:

WHERE
select TransactionNumber 
      from [bos_primary_db.dbo].[Transaction] 
      where Convert(VARCHAR, [Transaction].Date,103) >= CONVERT(VARCHAR,'02/02/2012' ,103)
      and  CONVERT(VARCHAR,[Transaction].Date,103) < CONVERT(VARCHAR,'03/02/2012',103)