Solved

TSQL Statement

Posted on 2015-01-13
3
60 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 47

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

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

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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