zoukankan      html  css  js  c++  java
  • SQL中如何将定义的变量作为列 别名 使用

    测试数据:

    create table test
    (
    value int not null
    )

    -----drop  table  test

    insert into test (value)
    select 2
    union all
    select 3
    union all
    select 2
    union all
    select 7
    union all
    select 6
    union all
    select 3
    union all
    select 5
    union all
    select 6
    union all
    select 8
    union all
    select 4
    union all
    select 9
    union all
    select 4
    union all
    select 1
    union all
    select 2

    select  *  from  test

    declare @cc int
    declare @str varchar(8000)
    set @cc=9999

    print @cc
    set @str='select value as '+'['+cast(@cc as varchar(10))+']'+'from test'
    print @str

     

     

    测试结果:

     

     

    7789

    可随意转载,欢迎署名!
  • 相关阅读:
    网页抓取
    基本数据结构
    小节
    顺序统计量
    线性时间排序
    快速排序
    堆排序 Heapsort
    大数运算
    趣味题,文本中洞的数量
    nginx config配置
  • 原文地址:https://www.cnblogs.com/netsa/p/2995142.html
Copyright © 2011-2022 走看看