sql - How to get many rows based on several uniqueidentifiers? -


itemprop = "text">

I'm trying to select one like this:

  announcement @ ContentIDs VARCHAR (max); Select @ContentIDs = 'e28faa48-Adea-484d-9d64-ba1e1c67eea3,8338A6DE-8CDF-4F52-99CE-62E2B107FF97' SELECT * FROM [content] where [ID] (@ContentIDs) in  

It only returns content with the first uniqueIdentifier

How can I get all the rows?

You

  1. Dynamic to generate query SQL But it will need to ensure that the list has been cleaned

  2. Use a partition function to parse the list and use it as a line Add each entry to a table variable, which you include on it or

  3. Use select * Sector [content] where '% cast like' @ContentIDs + ([ID] as varchar (36)) + < '%' / code> is forced to a full scan, but if you can match many rows This may not be the case. ( edit but if you are matching multiple rows then the comparison string will be huge!)

    Option 2 will usually be my preferred approach Or you can use CTE to do something (on the basis)

      announcement @SantanceIdS VARCHAR (Max); Set @ContentIDs = 'e28faa48-Adea-484d-9d64-ba1e1c67eea3,8338A6DE-8CDF-4F52-99CE-62E2B107FF97'; With GUIDs (PNS, initially, [off] as (1 selected as bigint), cast (1), CHARINDEX ( ',', @ContentIDs) UNION select all PN + 1, [pause] +1, CHARINDEX (',', Content IDs, [Stop] + 1) Select from where Gods [Stop]> Select & lt; Collist & gt; The [material] in WHERE [ID] (Select Cast (Eltiaraim (Artiaiaim (Sbstring (@ Kantentaidi start, the case when [stop]] gt; [THEN] [stop] Start ELSE LAN (@ContentIDs) END))) As UNIQUEIDENTIFIER) from Guids where [stop]> gt; or start> 1)  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -