新手问题 如何把 declare @变量的值 在sql中显示出来

sonicryu 2009-05-04 10:52:32
像高手求助

比如有这样的sql语句

declare @prostr nvarchar(50)

set @prostr= select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff')

现在可以用 @prostr做为条件来查询 比如 select from sample where id = @prostr

问题是 如果我想在企业管理器中查看 @prostr的 值的话 用什么函数?

比如 response.write 类似这样的输出函数在sql中输出的是什么
...全文
702 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
play7788 2009-05-05
  • 打赏
  • 举报
回复
print @变量 是以文本的方式在消息栏显示。

select @变量 是以表的形式在结果栏显示。
Zoezs 2009-05-04
  • 打赏
  • 举报
回复
用print,别select
ReyZhang 2009-05-04
  • 打赏
  • 举报
回复
print @prostr

or

select @prostr
claro 2009-05-04
  • 打赏
  • 举报
回复
帮顶。
lowsong 2009-05-04
  • 打赏
  • 举报
回复
不明白LZ意思。。
如果只是要在企业管理中看到该值,可以直接打开该库的syscolumns表
Brotter 2009-05-04
  • 打赏
  • 举报
回复
declare @prostr nvarchar(50)

set @prostr= select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff')

--查询变量值
print @prostr
select @prostr
ks_reny 2009-05-04
  • 打赏
  • 举报
回复

print(@prostr)
lgx0914 2009-05-04
  • 打赏
  • 举报
回复
print @prostr
htl258_Tony 2009-05-04
  • 打赏
  • 举报
回复
declare  @prostr  nvarchar(50)  

set @prostr= select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff')

--查询变量值
print @prostr
select @prostr
csdyyr 2009-05-04
  • 打赏
  • 举报
回复
print @prostr
select @prostr
conan304 2009-05-04
  • 打赏
  • 举报
回复
select @prostr
htl258_Tony 2009-05-04
  • 打赏
  • 举报
回复
declare  @prostr  nvarchar(50)  --声名

set @prostr= (select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff') ) --赋值

select * from sample where id = @prostr --调用
补个*
百年树人 2009-05-04
  • 打赏
  • 举报
回复
declare  @prostr  nvarchar(50)  

set @prostr= select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff')

print @prostr --或者 select @prostr
htl258_Tony 2009-05-04
  • 打赏
  • 举报
回复
declare  @prostr  nvarchar(50)  --声名

set @prostr= (select top 1 colorder from syscolumns where name= '性别' and id = object_id('G_staff') ) --赋值

select from sample where id = @prostr --调用
yanleiyigan 2009-05-04
  • 打赏
  • 举报
回复
print '...'
select '...'

或者直接抛个异常出来,无论在程序里还是sql里都能看到 ^_^
raiserror('...',11,1)
君_洛洛 2009-05-04
  • 打赏
  • 举报
回复
帮顶
abstract (关键字) 抽象 ['æbstrækt] access vt.访问,存取 ['ækses]'(n.入口,使用权) algorithm n.算法 ['ælgәriðm] Annotation [java] 代码注释 [ænәu'teiʃәn] anonymous adj.匿名的[ә'nɒnimәs]'(反义:directly adv.直接地,立即[di'rektli, dai'rektli]) apply v.应用,适用 [ә'plai] application n.应用,应用程序 [,æpli'keiʃәn]' (application crash 程序崩溃) arbitrary a.任意的 ['ɑ:bitrәri] argument n.参数;争论,论据 ['ɑ:gjumәnt]'(缩写 args) assert (关键字) 断言 [ә'sә:t] ' (java 1.4 之后成为关键字) associate n.关联(同伴,伙伴) [ә'sәuʃieit] attribute n.属性(品质,特征) [ә'tribju:t] boolean (关键字) 逻辑的, 布尔型 call n.v.调用; 呼叫; [kɒ:l] circumstance n.事件(环境,状况) ['sә:kәmstәns] crash n.崩溃,破碎 [kræʃ] cohesion 内聚,黏聚,结合 [kәu'hi:ʒәn] (a class is designed with a single, well-focoused purpose. 应该不止这点) command n. 命令,指令 [kә'mɑ:nd](指挥, 控制) (command-line 命令行) Comments [java] 文本注释 ['kɒments] compile [java] v.编译 [kәm'pail]' Compilation n.编辑[,kɒmpi'leiʃәn] const (保留字) constant n. 常量, 常数, 恒量 ['kɒnstәnt] continue (关键字) coupling 耦合,联结 ['kʌpliŋ] making sure that classes know about other classes only through their APIs. declare [java] 声明 [di'klєә] default (关键字) 默认; 缺省 [di'fɒ:lt] delimiter 定义符; 定界符 Encapsulation[java] 封装 (hiding implementation details) Exception [java] 例外; 异常 [ik'sepʃәn] entry n.登录项, 输入项, 条目['entri] enum (关键字) execute vt.执行 ['eksikju:t] exhibit v.显示, 陈列 [ig'zibit] exist 存在, 发生 [ig'zist] '(SQL关键字 exists) extends (关键字) 继承、扩展 [ik'stend] false (关键字) final (关键字) finally (关键字) fragments 段落; 代码块 ['frægmәnt] FrameWork [java] 结构,框架 ['freimwә:k] Generic [java] 泛型 [dʒi'nerik] goto (保留字) 跳转 heap n.堆 [hi:p] implements (关键字) 实现 ['implim

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧