用SQL Server数据库写了个存储过程,代码如下
create procedure proc_select
@id int
as
begin
if exists(select * from news where id=@id)
return 1
else
return 2
end
在C#中通过执行存储过程来获取返回值,但是返回的结果总是-1,纠结啊。在数据库中查询,是没有问题的...
分类:
数据库 时间:
2015-02-16 15:40:30
阅读次数:
191
Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically nei...
分类:
其他好文 时间:
2015-02-15 09:24:56
阅读次数:
191
public void GenerateData(string dbFullName) { bool bSuccess = true; if (File.Exists(dbFullName)) { ...
分类:
编程语言 时间:
2015-02-13 19:47:47
阅读次数:
204
if exists ( select * from dbo.sysobjects where id = object_id(N'[dbo].[TableSpace]') and objectproperty(id, N'IsUserTable') = 1 ) drop table [dbo].[T....
分类:
数据库 时间:
2015-02-13 16:13:47
阅读次数:
181
in和exists in 是把外表和内表作hash 连接,而exists是对外表作loop循环,每次loop循环再对内表进行查询。一直以来认为exists比in效率高的说法是不准确的。 如果查询的两个表大小相当,那么用in和exists差别不大。 如果两个表中一个较小,一个是大表,则子查询表大的用e...
分类:
其他好文 时间:
2015-02-13 10:08:03
阅读次数:
139
项目中遇到这么个情况:t1表 和 t2表 都是150w条数据,600M的样子,都不算大。但是这样一句查询 ↓select * from t1 where phone not in (select phone from t2)直接就把我跑傻了。。。十几分钟,检查了一下 phone在两个表都建了索引,字...
分类:
数据库 时间:
2015-02-12 19:58:40
阅读次数:
210
下面的存储过程从四个表的联接中返回所有作者(提供了姓名)、出版的书籍以及出版社。该存储过程不使用任何参数。USE pubs IF EXISTS (SELECT name FROM sysobjects WHERE name = 'au_info_all' AND type =...
分类:
数据库 时间:
2015-02-11 10:33:39
阅读次数:
205
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 mightbecome 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array...
分类:
其他好文 时间:
2015-02-11 09:27:00
阅读次数:
166
001_创建数据库和表--数据库的创建不能再事物中展开,因为创建数据库本身就是一个事物,平常应该注意避免嵌套事务--创建数据库TEST_BAKIF EXISTS ( SELECT 1 FROM sys.sysdatabases WHERE name = 'TEST_BAK' ) PRINT N'数据...
分类:
数据库 时间:
2015-02-10 23:03:54
阅读次数:
426
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-02-10 15:06:02
阅读次数:
172