SQL server获取数据库数据

本文介绍了在SQL Server中进行数据库操作的一些实用技巧,包括如何进行两表对比以找出A表中缺失的字段,如何获取特定表的列信息,以及如何查询存储过程的参数详情。
摘要由CSDN通过智能技术生成

两表对比,查询A表中缺少的字段

select a.name as name,b.name as xtype,a.length as length,a.xprec as xprec,a.xscale as xscale
                      from (select name,xtype,length,xprec,xscale from syscolumns where id=object_id('T_HR_Employee') and name not in(select name from syscolumns where id=object_id('T_HR_EmployeeSnapshot'))) a,
                     systypes b 
                      where a.xtype=b.xtype and b.name!='sysname'

例如

//人员快照表与员工表对比,查询人员快照表中缺少的字段名
                    string sqlqueryEmp = string.Format(@"select a.name as name,b.name as xtype,a.length as length,a.xprec as xprec,a.xscale as xscale
                      from (select name,xtype,length,xprec,xscale from syscolumns where id=object_id('T_HR_Employee') and name not in(select name from syscolumns where id=object_id('T_HR_EmployeeSnapshot'))) a,
                     systypes b 
                      where a.xtype=b.xtype and b.name!='sysname'", VersionID);
                    DataTable dt = DbHelper.QueryForDataTable(sqlqueryEmp);

                    //汇总查出的数据总数
                    // int count2 = (int)this.DbHelper.QueryForScalar(sqlqueryEmp);

                    //判断有无数据
                    //判断汇总查出的数据总数是否大于0
                    if (dt.Rows
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值