加入收藏 | 设为首页 | 会员中心 | 我要投稿 通辽站长网 (https://www.0475zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

Sql server 在sql server中的表中插入值

发布时间:2022-10-13 14:01:14 所属栏目:MsSql教程 来源:未知
导读: Sql server 在sql server中的表中插入值
sql-server
Sql server 在sql server中的表中插入值,sql-server,Sql Server,我在SQLServer中创建了一个表“records”,作为create table records(n

Sql server 在sql server中的表中插入值

sql-server

Sql server 在sql server中的表中插入值,sql-server,Sql Server,我在SQLServer中创建了一个表“records”,作为create table records(name varchar(20),countvalue int);我使用下面的语句插入一条记录insert into records values('&name', &countvalue);此语句在countvalue处给我一个错误。错误是什么?您不需要&countValue之前mssql 在表中插入,我想您的意思是@countValuedeclare @countValue int

我在SQLServer中创建了一个表“records”,作为

create table records(name varchar(20),countvalue int);

我使用下面的语句插入一条记录

insert into records values('&name', &countvalue);

此语句在countvalue处给我一个错误。错误是什么?

您不需要&countValue之前,我想您的意思是@countValue

declare  @countValue int 
set @countValue = 1
insert into records values('&name', @countvalue);

此外,如果需要分配名称,则必须使用此查询

declare  @countValue int 
declare @name varchar(20)
set @countValue = 1
set @name = 'name'
insert into records values(@name, @countvalue);

(编辑:通辽站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!