表变量用自定义类型时类型在当前库有效。
临时表用自定义类型时类型在tempdb库有效。
以下测试3个例子:
sql]-测试例子1:在test创建自定义类型ssn
use tempdb
go if object_id('tempdb..#testtable') is not null
drop table #testtable;
if exists (select 1 from types where name = ssn')
drop type
go use test
go if exists (select 1 from where name = ssn')
drop type
go -在test创建自定义类型
create type
from char(9) not null
go raiserror('定义表变量成功',10,1) with nowait;
declare @testtable table (
rowid int identity,
ssn ssn)
go raiserror('创建临时表失败',10,1) with nowait;
create table #testtable (
rowid int identity,
ssn ssn)
定义表变量成功
消息 2715,级别 16,状态 7,第 3 行
第 2 个列、参数或变量: 找不到数据类型 ssn。
go sql]
-测试例子2:在tempdb创建自定义类型ssn
use test
go if exists (select 1 from where name = ssn')
drop type
go use tempdb
go if object_id('tempdb..#testtable') is not null
drop table #testtable;
if exists (select 1 from where name = ssn')
drop type
go -在tempdb创建自定义类型
create type
from char(9) not null;
go use test
go raiserror('定义表变量失败',10,1) with nowait;
declare @testtable table (
rowid int identity,
ssn ssn)
go raiserror('创建临时表成功',10,1) with nowait;
create table #testtable (
rowid int identity,
ssn ssn)
消息 2715,级别 16,状态 7,第 3 行
第 2 个列、参数或变量: 找不到数据类型 ssn。
创建临时表成功
go sql]
-测试例子3:同时在tempdb和test创建自定义类型ssn
use tempdb
go if object_id('tempdb..#testtable') is not null
drop table #testtable;
if exists (select 1 from where name = ssn')
drop type
go create type
from char(9) not null;
go use test
go if exists (select 1 from where name = ssn')
drop type
go create type
from char(9) not null;
go raiserror('定义表变量成功',10,1) with nowait;
declare @testtable table (
rowid int identity,
ssn ssn)
go raiserror('创建临时表成功',10,1) with nowait;
create table #testtable (
rowid int identity,
ssn ssn)
定义表变量成功
创建临时表成功
变量声明表
在回答你的问题之前,有必要对变量声明表有一个基本了解。在step7中有两种用来定义符号地址的 形式 符号表 共享符号 和变量声明表 局域符号 其本质都是为了建立绝对地址与符号地址之间的内在联系,但 针对的对象不同。共享符号是整个程序所使用的共同符号 用于全局符号定义的表为符号表 而局域符号是某一特定...
保密自查自评表
附件 机关 单位保密自查自评标准。处室 办 名称 市 xx填写时间 2018年 1月x日。说明 1.本自评标准的评分项目根据 机关 单位保密自查自评工作规则 设置,共59小项。其中,第1至50小项设置总分值为100分 第51至58小项为加重扣分项,不设分值 第59小项为否决项。2.根据 机关 单位保...
保密自查自评表
附件 机关 单位保密自查自评标准。处室 办 名称 市 xx填写时间 2018年 1月x日。说明 1.本自评标准的评分项目根据 机关 单位保密自查自评工作规则 设置,共59小项。其中,第1至50小项设置总分值为100分 第51至58小项为加重扣分项,不设分值 第59小项为否决项。2.根据 机关 单位保...