ms sql 一次插入多条记录的语句
有的时候我们需要一次像数据库中添加多条记录,我们可以使用下面的语句来实现:
--添加一条记录
INSERT INTO tableName(col1,col2,col3) VALUES (1,2,3)
--添加多条记录
INSERT INTO tableName(col1,col2,col3)
SELECT 3,4,5
UNION ALL
SELECT 6,7,8
--从另外的一张表中读取多条数据添加到新表中
INSERT INTO tableName(col1,col2,col3)
SELECT a,b,c from tableA
--从其他的多张表中读取数据添加到新表中
INSERT INTO tableName(col1,col2,col3)
SELECT a,b,c from tableA WHERE a=1
UNION ALL
SELECT a,b,c from tableB WHERE a=2
在mysql可以这样
insert
into
tablefortest(a,b)
values
(
1
,
2
) ,(
3
,
4
) ,(
5
,
6
)
相关文档:
asp.net(C#)实现SQL2000数据库备份和还原
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.Htm ......
SQL like子句的另一种实现方法,速度比like快(转)
一般来说使用模糊查询,大家都会想到LIKE
select * from table where a like '%字符%'
如果一个SQL语句中用多个 like模糊查询,并且记录条数很大,那速度一定会很慢。
下面两种方法也可实现模糊查询:
select * from table where patindex('%字符%',a)>0 ......
今天在一个VPS上安装sql2005,安装好后本地一直连接不上
简介
在尝试从远程计算机连接到 Microsoft SQL Server 2005 实例时,可能会接收到错误消息。在使用任何程序连接到 SQL Server 时都可能会发生此问题。例如,在使用 SQLCMD 实用工具连接到 SQL Server 时收到以下错误消息:
Sqlcmd:错误:Microsoft SQL Native Cli ......
declare @SchemaName nvarchar(50)
set @SchemaName='dbo'
declare @CommandName nvarchar(50)
set @CommandName='spName'
SELECT
DB_NAME() AS [PROCEDURE_CATALOG],
  ......
C# 数据库之旅……
继续进攻层出不穷的problems
在上一篇内容的基础上,我又作以改进,现在的情况是这样的:
//In Browseuser form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System ......