Solved

TSQL Statement

Posted on 2015-01-13
3
65 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need multiple Group By's 8 55
How do I partition this table on date? 5 55
Replacing unrecognized function name in SQL Query 4 49
Create a Calendar table 29 45
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…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…

752 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