问几个小问题,
一:在SQL中,怎样利用变量把Select count(*)语句查询出的结果取出来?最好给一小段代码!二:在SQL中,在字符串怎样把单引号显示出来?谢谢帮忙。

解决方案 »

  1.   

    一:在SQL中,怎样利用变量把Select count(*)语句查询出的结果取出来?最好给一小段代码!
    declare @int int
    select @int=(select count(*) from sysct)
    select @int二:在SQL中,在字符串怎样把单引号显示出来?谢谢帮忙。
    select * from tablename where charindex('''',col)>0
      

  2.   

    问几个小问题,
    一:在SQL中,怎样利用变量把Select count(*)语句查询出的结果取出来?最好给一小段代码!declare @count int
    set @count=(select count(*) from tb)
    -- 或者
    select @count=count(*) from tb二:在SQL中,在字符串怎样把单引号显示出来?谢谢帮忙。
    print 'a''b'
      

  3.   

    可能是我没交代清楚单引号的问题例如exec('select * from A where b like '%123456%'')其中括号里面的单引号的用法是不对的,请教一下正确的该怎样使用。
      

  4.   

    exec('select * from A where b like '%123456%''')
      

  5.   

    exec('select * from A where b like ''%123456%''')
      

  6.   

    print 'a''b'   这个可以   但不知道有没转义符作用于"'"上使其输出?
      

  7.   

    (2)print'''大家'''       两个单引号表示一个单引号
    (1)declare @count int
    select @count=count(*) from tablename
      

  8.   

    (1)declare @count int 
         set @count=(select count(*) from tb)
     (2)把'' 替换成''''
      

  9.   

    execute('select * from uos_org where org_name like ''%%'''连续两个单引号"''"会最终拼接成字符串时转换为一个"'".试试吧