存储过程, 生成SQL语句
USE [sfaecrm]
GO
/****** 对象: StoredProcedure [dbo].[proc_insert] 脚本日期: 05/29/2009 06:16:07 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER proc [dbo].[proc_insert] (@tablename varchar(256))
as
begin
set nocount on
declare @sqlstr varchar(4000)
declare @sqlstr1 varchar(4000)
declare @sqlstr2 varchar(4000)
select @sqlstr='select ''insert '+@tablename
select @sqlstr1=''
select @sqlstr2=' ('
select @sqlstr1= ' values ( ''+'
select @sqlstr1=@sqlstr1+col+'+'',''+' ,@sqlstr2=@sqlstr2+name +',' from (select case
-- when a.xtype =173 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar('+convert(varchar(4),a.length*2+2)+'),'+a.name +')'+' end'
when a.xtype =127 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(20),'+a.name +')'+' end'
when a.xtype =104 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(1),'+a.name +')'+' end'
when a.xtype =175 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'replace('+a.name+','''''''','''''''''''')' + '+'''''''''+' end'
when a.xtype =61 then 'case when '+a.name+' is null then ''NULL'' else '+'''''''''+'+'convert(varchar(23),'+a.name +',121)'+ '+'''''''''+' end'
when a.xtype =106 then 'case when '+a.name+' is null then ''NULL'' else '+'convert(varchar(
相关文档:
http://zhanglei1286.blog.163.com/blog/static/1895797120091112113019600/
在后台代码里:
SQL 2000:
static string StrConn = "server=.;uid=sa;pwd=sa;database=MyCUDS";
SQL2005:
con = new SqlConnection(@"Server=.\SQLExpress;Database=db_CMS;Persist Security Info=True;User ID=sa;Password=Masslong");
......
用TSQL把Access的表导入到远程Sql Server:
把access 的.mdb里t_itemList 表的数据插入到远程SqlServer的t_itemL1111111表里。
SELECT top 10 * INTO t_itemL1111111 IN [ODBC]
[ODBC;Driver=SQL Server; UID=jyb;PWD=jyb;Server=10.1.18.49;DataBase=所有合并;]
&nb ......
[code=SQL][/code]
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据 ......
Microsoft SQL Server 2005 JDBC Driver
1.1
快速描述
下载 Microsoft SQL Server
2005 JDBC Driver 1.1,这是一种 Type 4 JDBC 驱动程序,可通过 J2EE(Java2 企业版)中的标准 JDBC
应用程序编程接口 (API) 提供数据库链接。
本页内容
快
速详细信息
概
述
系
统要求
说
明
相
关资源
其
他用户正在 ......
linq to sql 在插入值的时候还是很方便。有时候我们需要在插入一个新的实体之后得到那个实体的主键ID的值,这个ID当然必须是自增。一段时间我一直认为直接使用linq to sql的插入机制是不可以在做到的,所以只有使用存储过程的,具体可以查看这篇文章:http://blog.benhall.me.uk/2008/01/custom-insert-logic-with-linq-to- ......