摘要: 下文讲述sqlserver中,更新脚本中常用if exists关键字的用法说明,如下所示: 实验环境:sql server 2008 R2 一.检测数据库是否存在于当前数据库引擎下 if exists (select * from sys.databases where name = ’数据库名称’) begin print '数据库名称--存在' end 二.检测数据表是否存在于指定数据库下 ) begin print '数据表名称---存在' end 三.检测存储过程是否存在的方法
转自:http://blog.sina.com.cn/s/blog_6739945f0100zt4b.html 在 Linux 下,不管你是启动一个桌面程序也好,还是在控制台下运行命令,所有的程序在结束时,都会返回一个数字值,这个值叫做返回值,或者称为错误号 ( Error Number ). 在控制台下,有一个特殊的环境变量 $?,保存着前一个程序的返回值,我们可以试试: $ ls *.pngDiagram1.png eqn.png peazip.pngeqn4.png
整理一下级联更新和删除 c#调用返回值 use master go IF exists(select 1 from sysdatabases where name='temp') BEGIN DROP DATABASE temp END create database temp go use temp go --drop table ProductInfo create table ProductInfo ( ProductId int primary key , ProductName var
1.存储过程中不使用外部参数. 存储过程: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: HF_Ultrastrong -- Create date: 2015年7月19日22:09:24 -- Description: 判断是否有数据,并使用Return返回值 -- =============================
1.Output参数返回值 1 CREATE PROCEDURE [dbo].[upInformation]( 2 @age int , 3 @id bigint OUTPUT 4 ) 5 AS 6 BEGIN 7 SET NOCOUNT ON; 8 BEGIN 9 INSERT INTO [Information](age ) 10 VALUES (@age ) 11 SET @id = @@IDENTITY 12 END 13 END 存储过程中获得方法: 1 DECLARE @age in
过程1:带返回值: 1 drop procedure if exists proc_addNum; 2 create procedure proc_addNum (in x int,in y int,out sum int) 3 BEGIN 4 SET sum= x + y; 5 end 然后,执行过程,out输出返回值: 1 call proc_addNum(2,3,@sum); 2 select @sum; 过程2:不带返回值: 1 drop procedure if exists proc
1.OUPUT参数返回值 CREATE PROCEDURE [dbo].[nb_order_insert]( @o_buyerid int , @o_id bigint OUTPUT ) AS BEGIN SET NOCOUNT ON; BEGIN INSERT INTO [Order](o_buyerid ) VALUES (@o_buyerid ) SET @o_id = @@IDENTITY END END 存储过程中获得方法: DECLARE @o_buyerid int DECLARE
因为msdn中说返回受影响的行数: Executes a Transact-SQL statement against the connection and returns the number of rows affected. 但是却没看到备注里说 For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. When a trigger e