Solved

TSQL Statement

Posted on 2015-01-13
3
54 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 45

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

20 Experts available now in Live!

Get 1:1 Help Now