SQLSERVER 添加一个不可为空的字段
SqlServer 表中当之前有记录的时候发现表设计的不合理要加字段,
但是alter table Skating_Consumption add MemberCardId numeric(9)只能加可为空的字段,
解决办法,
第一、加个为空的字段
第二、更新表中记录这个字段为某个值
第三、再更改表字段为非空
语句
alter table Skating_Consumption add MemberCardId numeric(9)
go
update Skating_Consumption set MemberCardId='0'
go
ALTER TABLE Skating_Consumption ALTER COLUMN
MemberCardId numeric(9) not null
相关文档:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
public class CommandInfo
{
public string CommandText;
public SqlPa ......
什么是存储过程呢?
定义:
将常用的或很复杂的工作,预先用SQL语句写好并用一个指定的名称存储起来, 那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。
讲到这里,可能有人要问:这么说存储过程就是一堆SQL语句而已啊?
Microsoft公司为什么还 ......
写了一个存储过程对视图进行分页查询,但数据增多后发现基效率低得要命,三万多条数据要查询一个半小时都没出来,这不是要了命,于是想到了索引,应用过后仍无济于事。最后对sql进行分析和实践中得出,使用临时表可以大大加快视图的查询速度,见如下sql语句
性能超低的视图分页sql语句:
select top 100 * from
view_c ......
/*drop table scourse
drop table course
drop table student
drop table major*/
create database db
use db
--专业表
create table major
(spno char(5) not null primary key,
spname varchar(20) not null,
pno char(2) )
--学生表
create table student
(sno char(7) not null primary key,
......
字符串函数:
● ASCII('a')=97---返回字母a对应的ASCII码
● CHAR('48')=0---返回48这个ASCII码对应的字符
● LCASE('ABcdE')="abced" 或 LOWER('ABcdE')="abced"(将给定字符串转为小写)
● UCASE('ABcdE')="ABCDE" 或 UPPER('ABcdE')="ABCDE"(将给定字符串转为大写)
● LTRIM(' fgf gh ')="fgf ......