Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Table variables in sql query

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

In this issue, the editor will bring you about how to use table variables in sql query. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

The copy code is as follows: USE [DAF_DB] GO / * Object: StoredProcedure [dbo]. [PROG_WORKTASK_List] Script Date: 06Charger 21:14:43 * / SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO-- [PROG_WORKTASK_List] 62meme-- =-- Author: guo.lin-- Create date: 2010-03-10-- Description: get a list of work orders According to the relevant conditions-- = ALTER PROCEDURE [dbo]. [PROG_WORKTASK_List] @ userID varchar (10),-current user @ status int,-- status @ Leader varchar (30), @ Facilitators varchar (30), @ Level int, @ Priority int, @ CloseDT varchar (30), @ CreatedBy varchar (30) AS BEGIN declare @ result table (taskid int, TaskName nvarchar, TaskTopic nvarchar, Level varchar, Priority varchar (10), Status varchar (10) Leader varchar, strLeader nvarchar, Facilitators varchar, cycletime varchar, CloseDT datetime, Createddt datetime, CreatedBy varchar) insert into @ result select taskid,TaskName,TaskTopic,Level,Priority,Status,Leader,strLeader,Facilitators,cycletime,CloseDT,Createddt CreatedBy from Work_TaskProcess where createdby=@CreatedBy or leader like'% |'+ @ userid+' |%'or Facilitators like'% |'+ @ userid+' |%'if (@ status 0) delete @ result where status@status if (@ Leader'') delete @ result where leader not like'% |'+ @ Leader+' |%'- if (@ CreatedBy'')-delete @ result where CreatedBy@CreatedBy if (@ Level 0) delete @ result where level@level if (@ Priority 0) delete @ result where Priority@ Priority if (@ CloseDT'') delete @ result where CloseDT@CloseDT update @ result set status=b.itemtext from @ result a DAF_Item b where a.Status=b.itemvalue and b.itemtypewriter worktaskStatus' update @ result set Level=b.itemtext from @ result set Level=b.itemtext from @ result _ useraccount b where a.createdBy=b.userid update @ result set createdby=b.username from @ result _ useraccount b where a.createdBy=b.userid update @ result set Priority=b.itemtext from @ result CreatedBy from @ result order by Createddt desc END

This is how to use table variables in the sql query shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report