Solved

TSQL Statement

Posted on 2015-01-13
3
63 Views
Last Modified: 2015-01-19
How to set the INVENTBATCHID in order to pass multiple BatchID for query ? What's the maximum NVARCHAR that I can set as I may pass many BATCHID for the query...

Tks


DECLARE @INVENTBATCHID NVARCHAR(300)
SET @INVENTBATCHID= 'P000114328'
select * from INVENTBATCH where INVENTBATCHID in (@INVENTBATCHID)
0
Comment
Question by:AXISHK
3 Comments
 
LVL 48

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 150 total points
ID: 40546121
If you declare as NVARCHAR(MAX) is almost unlimited and you'll need to separate the ID by commas, like
SET @INVENTBATCHID= 'P000114328, P000114329, P000114330, ...'

But if you have plenty of ID's I'ld recommend you to work with a temptable, so your code should be something like this:
select * 
from INVENTBATCH
inner join #TempBatchID on INVENTBATCH.INVENTBATCHID #TempBatchID=INVENTBATCHID

Open in new window

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 350 total points
ID: 40546122
0
 

Author Closing Comment

by:AXISHK
ID: 40559009
Tks
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question