zoukankan      html  css  js  c++  java
  • mssql 容易掉进的坑

    1.     重复 使用 into #tabel(不是在开头使用insert into ) 会报错   if  1=1 begin  select *

    into #tabel from productoin

    end else begin

     select * into #tabel from productoin

    end

    2.  select top 100  cus ,*     from  mytable   order by cus   --  这样会出现异常  因为出现两列  cus  ,无法判断具体是那一列排序

     --    正确 :  order by cus  修改为 order by  mytable.cus

    3.   select top 100  cus , name ,tech   from  mytable    group   by cus  --出错   正确应该为:   group   by  cus , name ,tech

    4. 在存储过程中这样写

    if  @df='N' begin

    end   -- begin  end 内部没有任何内容, 空着 会出错 (加上 ; 也是) 最好注释掉 或者  内容添加  -- 修正后为 也可以: if  @df='N' begin select '' end

    5 . 调用有参数的存储过程 参数 不应该有  括号   方法  应该有 括号 ,方法返回的时候是 returns 不是return  .调用的时候应该有dbo.functionname   --注意一定要有dbo. 

    6.  insert into  #t select  a,b,c from tablename    和     select a,b,c  into #t  from tablename       使用  insert into  #t select   需要事先声明 create table #t         select a,b,c  into #t   为系统自动创建   

  • 相关阅读:
    Wayland中的跨进程过程调用浅析
    设计模式总结
    C语言---整型字符串转换
    抽象工厂模式
    SVNclient安装与使用
    [置顶] MyEclipse下安装插件方法(properties文件编辑器Propedit为例)
    脑筋急转弯的歧义性
    脑筋急转弯的歧义性
    从和式积分到定积分
    从和式积分到定积分
  • 原文地址:https://www.cnblogs.com/bkyrslf/p/4142303.html
Copyright © 2011-2022 走看看