search
HomeDatabaseMysql Tutorial佩特来项目经验小集合(2)___组合查询存储过程,报错"va
佩特来项目经验小集合(2)___组合查询存储过程,报错"vaJun 07, 2016 pm 03:59 PM
ampstorageReport an errorInquirecombinationexperienceprocessgatherproject

今天写一个组合查询的存储过程遇到这样一个问题: 在将 varchar 'SELECT * FROM View_DLS_WXJD_Customer WHERE 1=1 and JBID ='' 转换成数据类型 int 时失败。错误详情如图所示: 经百度:字符串变量和整型变量连接不能用连接。于是我采用 cast() 函数将DLSJB

今天写一个组合查询的存储过程遇到这样一个问题:在将 varchar 值 'SELECT * FROM View_DLS_WXJD_Customer WHERE 1=1 and JBID ='' 转换成数据类型 int 时失败。错误详情如图所示: \ 经百度:字符串变量和整型变量连接不能用+连接。于是我采用cast()函数将DLSJB这个整型变量转换成字符串,这样问题就解决了。正确代码如下所示:
ALTER PROCEDURE [dbo].[Proc_SH_WXJDList]
	@DH varchar(50),       --单号
	@DLSJB int,    --代理商级别ID
	@DLSName varchar(100)   --代理商姓名
AS
BEGIN
Declare @sqlStr varchar(800)  --存储sql语句
	
	Set @sqlStr = 'SELECT * FROM View_DLS_WXJD_Customer WHERE 1=1'	--合成sql语句,不输入条件则选择全部
	
	 if(@DH!='')									--判断是写单号
		set @sqlStr = @sqlStr + ' and DH like ''%' + @DH + '%''' 
	if(@DLSJB!= -1 )	                    --判断是否选择代理商级别
		set @sqlStr = @sqlStr + ' and JBID ='+''''+cast(@DLSJB as varchar(5))+''''
	if(@DLSName!='')										--判断是否选择代理商名
		set @sqlStr = @sqlStr + ' and DLSName like ''%' + @DLSName + '%''' 	
	EXEC (@sqlStr + 'ORDER BY DH DESC')			
END

cast()是一个转换函数,跟我们在asp.net中使用的Convert函数一样,都是一种数据类型转换到另一种数据类型。这篇文章恰恰是使用cast()函数使整型变量强制转换成字符串型,这样字符串型之间就可以使用+进行连接了。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
分享PyCharm项目打包的简易方法分享PyCharm项目打包的简易方法Dec 30, 2023 am 09:34 AM

简单易懂的PyCharm项目打包方法分享随着Python的流行,越来越多的开发者使用PyCharm作为Python开发的主要工具。PyCharm是功能强大的集成开发环境,它提供了许多方便的功能来帮助我们提高开发效率。其中一个重要的功能就是项目的打包。本文将介绍如何在PyCharm中简单易懂地打包项目,并提供具体的代码示例。为什么要打包项目?在Python开发

PyCharm实用技巧:将项目转换为可执行EXE文件PyCharm实用技巧:将项目转换为可执行EXE文件Feb 23, 2024 am 09:33 AM

PyCharm是一款功能强大的Python集成开发环境,提供了丰富的开发工具和环境配置,让开发者能够更高效地编写和调试代码。在使用PyCharm进行Python项目开发的过程中,有时候我们需要将项目打包成可执行的EXE文件,以便在没有安装Python环境的计算机上运行。本文将介绍如何使用PyCharm将项目转换为可执行的EXE文件,同时给出具体的代码示例。首

制作 iPhone 上 iOS 17 提醒应用程序中的购物清单的方法制作 iPhone 上 iOS 17 提醒应用程序中的购物清单的方法Sep 21, 2023 pm 06:41 PM

如何在iOS17中的iPhone上制作GroceryList在“提醒事项”应用中创建GroceryList非常简单。你只需添加一个列表,然后用你的项目填充它。该应用程序会自动将您的商品分类,您甚至可以与您的伴侣或扁平伙伴合作,列出您需要从商店购买的东西。以下是执行此操作的完整步骤:步骤1:打开iCloud提醒事项听起来很奇怪,苹果表示您需要启用来自iCloud的提醒才能在iOS17上创建GroceryList。以下是它的步骤:前往iPhone上的“设置”应用,然后点击[您的姓名]。接下来,选择i

基于开源的 ChatGPT Web UI 项目,快速构建属于自己的 ChatGPT 站点基于开源的 ChatGPT Web UI 项目,快速构建属于自己的 ChatGPT 站点Apr 15, 2023 pm 07:43 PM

作为一个技术博主,了不起比较喜欢各种折腾,之前给大家介绍过ChatGPT​接入微信,钉钉和知识星球(如果没看过的可以翻翻前面的文章),最近再看开源项目的时候,发现了一个ChatGPTWebUI项目。想着刚好之前没有将ChatGPT​接入过WebUI,有了这个开源项目可以拿来使用,真是不错,下面是实操的安装步骤,分享给大家。安装官方在Github​的项目文档上提供了很多中的安装方式,包括手动安装,docker​部署,以及远程部署等方法,了不起在选择部署方式的时候,一开始为了简单想着

react启动项目报错怎么办react启动项目报错怎么办Dec 27, 2022 am 10:36 AM

react启动项目报错的解决办法:1、进入项目文件夹,启动项目并查看报错信息;2、执行“npm install”或“npm install react-scripts”命令;3、执行“npm install @ant-design/pro-field --save”命令。

PyCharm教程:如何在PyCharm中移除项目?PyCharm教程:如何在PyCharm中移除项目?Feb 24, 2024 pm 05:54 PM

PyCharm是一款功能强大的Python集成开发环境(IDE),提供了丰富的功能帮助开发者更高效地编写和管理Python项目。在使用PyCharm开发项目的过程中,有时候我们需要删除一些不再需要的项目以释放空间或清理项目列表。本文将详细介绍如何在PyCharm中删除项目,并提供具体的代码示例。如何删除项目打开PyCharm,进入项目列表界面。在项目列表中,

基础教程:使用IDEA创建Maven项目基础教程:使用IDEA创建Maven项目Feb 19, 2024 pm 04:43 PM

IDEA(IntelliJIDEA)是一款强大的集成开发环境,可以帮助开发人员快速高效地开发各种Java应用程序。在Java项目开发中,使用Maven作为项目管理工具能够帮助我们更好地管理依赖库、构建项目等。本文将详细介绍如何在IDEA中创建一个Maven项目的基本步骤,同时提供具体的代码示例。步骤一:打开IDEA并创建新项目打开IntelliJIDEA

快速掌握PyCharm项目打包的基础知识快速掌握PyCharm项目打包的基础知识Dec 30, 2023 pm 01:17 PM

从零开始,快速上手PyCharm项目打包技巧概述:在Python开发中,将项目打包成可执行文件是非常重要的一步。它可以方便地分享和分发项目,而无需安装Python解释器和依赖包。PyCharm作为一个功能强大的Python集成开发环境,提供了快速上手项目打包的技巧和工具。本文将介绍如何利用PyCharm从零开始打包你的Python项目,并提供具体的代码示例。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.