交换表的两列:update table as a, table as b set a.f1=b.f2, a.f2=b.f1 where a.id=b.id;
转移表:select * into T2 from T1
把T1的表结构和数据导入到T2(未创建)中。
set identity_insert T3 on
insert into T3(id,f2,f3,....) select * from T1
set identity_insert T3 off
把T1的数据导入到T3表中,其中id为主键自动增长。
自定义函数:
drop function dbo.input --删除函数
go
create function dbo.input --定义函数 架构.方法名
(
@num1 int, --输入参数
@num2 int = null, --可选参数
@oper varchar = '+' --默认参数
)
returns int
as
begin
declare @sum int
if(@oper='+')
begin
set @sum = @num1 + @num2
end
else
begin
set @sum = 0
end
return @sum
end
go
select dbo.input(1,null,default) --参1必填,参2可选,参3默认
select dbo.input(1,2,default) --输出3
select dbo.input(1,2,'*') --输出0 *没判断
https://blog.youkuaiyun.com/nyist327/article/details/45074559
开放mysql数据库给远程连接:
GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@'%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;