Solved

TSQL Statement

Posted on 2015-01-13
3
56 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 46

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 142

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now