Check if a certain value exist in the passed parameter in query (SQL SERVER)
So I need to determine if a certain value exist in the passed parameter to perform a certain condition. Here's the query below:
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
('ON-HOLD' IN (@PCStatus)
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
so what i need is to check if the parameter sent contain the value 'ON-HOLD' to perform the EffectiveDate condition being equal or less than today.
sql sql-server report condition
add a comment |
So I need to determine if a certain value exist in the passed parameter to perform a certain condition. Here's the query below:
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
('ON-HOLD' IN (@PCStatus)
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
so what i need is to check if the parameter sent contain the value 'ON-HOLD' to perform the EffectiveDate condition being equal or less than today.
sql sql-server report condition
since you are usingIN
I suspect the@PCStatusas
is a comma separated string. If so, yourIN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter
– scsimon
Nov 15 '18 at 5:18
can you please verify and re-format your query properly. Example is it suppose to be@PCStatusas
orDECLARE @PCStatus as varchar(50);
?
– Squirrel
Nov 15 '18 at 5:30
add a comment |
So I need to determine if a certain value exist in the passed parameter to perform a certain condition. Here's the query below:
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
('ON-HOLD' IN (@PCStatus)
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
so what i need is to check if the parameter sent contain the value 'ON-HOLD' to perform the EffectiveDate condition being equal or less than today.
sql sql-server report condition
So I need to determine if a certain value exist in the passed parameter to perform a certain condition. Here's the query below:
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
('ON-HOLD' IN (@PCStatus)
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
so what i need is to check if the parameter sent contain the value 'ON-HOLD' to perform the EffectiveDate condition being equal or less than today.
sql sql-server report condition
sql sql-server report condition
asked Nov 15 '18 at 5:08
Elijah ElcanoElijah Elcano
103
103
since you are usingIN
I suspect the@PCStatusas
is a comma separated string. If so, yourIN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter
– scsimon
Nov 15 '18 at 5:18
can you please verify and re-format your query properly. Example is it suppose to be@PCStatusas
orDECLARE @PCStatus as varchar(50);
?
– Squirrel
Nov 15 '18 at 5:30
add a comment |
since you are usingIN
I suspect the@PCStatusas
is a comma separated string. If so, yourIN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter
– scsimon
Nov 15 '18 at 5:18
can you please verify and re-format your query properly. Example is it suppose to be@PCStatusas
orDECLARE @PCStatus as varchar(50);
?
– Squirrel
Nov 15 '18 at 5:30
since you are using
IN
I suspect the @PCStatusas
is a comma separated string. If so, your IN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter– scsimon
Nov 15 '18 at 5:18
since you are using
IN
I suspect the @PCStatusas
is a comma separated string. If so, your IN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter– scsimon
Nov 15 '18 at 5:18
can you please verify and re-format your query properly. Example is it suppose to be
@PCStatusas
or DECLARE @PCStatus as varchar(50);
?– Squirrel
Nov 15 '18 at 5:30
can you please verify and re-format your query properly. Example is it suppose to be
@PCStatusas
or DECLARE @PCStatus as varchar(50);
?– Squirrel
Nov 15 '18 at 5:30
add a comment |
3 Answers
3
active
oldest
votes
You can do like (@PCStatus like '%ON-HOLD%')
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
(@PCStatus like '%ON-HOLD%')
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
add a comment |
So with the help of my colleague, we created a function that splits the csv into a temporary table and there I can simply check if a certain value is in the temporary table and return a Boolean for it. Thanks for the help guys.
if you are usingSQL Server 2016
or later you can useSTRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993
– Squirrel
Nov 16 '18 at 3:29
add a comment |
If you have mix AND
and OR
conditions, it is best to use parenthesis ( )
on it to clearly define the intended conditions.
Also avoid applying function on the column as it will prohibit the use of index on the column. If the EffectiveDate does not contain time, you may simply use equal emp.EffectiveDate = CAST(GETDATE() AS DATE)
else you should use >= today
and < tomorrow
DECLARE @PCStatus as varchar(50);
SELECT *
FROM Employee emp
WHERE
(
emp.PCStatus = @PCStatus
)
OR
(
@PCStatus = ''
)
OR
(
@PCStatus LIKE '%ON-HOLD%'
AND emp.EffectiveDate >= CAST(GETDATE() AS DATE)
AND emp.EffectiveDate < CAST(DATEADD(DAY, 1, GETDATE()) AS DATE)
)
EDIT : change to LIKE '%ON-HOLD%'
EDIT 2 : @PCStatus is CSV
here, the query is using STRING_SPLIT()
if you are using earlier version of SQL Server, use the DelimitedSplit8K
that i posted in the comments
DECLARE @PCStatus as varchar(50) = 'ACTIVE,ON-HOLD';
SELECT *
FROM Employee emp
WHERE
(
@PCStatus = ''
OR EXISTS
(
select *
from STRING_SPLIT(@PCStatus, ',') x
where x.value = emp.PCStatus
)
)
AND
(
emp.PCStatus <> 'ON-HOLD'
OR emp.EffectiveDate <= CAST(GETDATE() AS DATE)
)
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want
– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312789%2fcheck-if-a-certain-value-exist-in-the-passed-parameter-in-query-sql-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can do like (@PCStatus like '%ON-HOLD%')
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
(@PCStatus like '%ON-HOLD%')
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
add a comment |
You can do like (@PCStatus like '%ON-HOLD%')
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
(@PCStatus like '%ON-HOLD%')
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
add a comment |
You can do like (@PCStatus like '%ON-HOLD%')
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
(@PCStatus like '%ON-HOLD%')
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
You can do like (@PCStatus like '%ON-HOLD%')
DECLARE @PCStatusas varchar(50);
SELECT * FROM
Employee emp
WHERE (emp.PCStatus IN (@PCStatus) OR @PCStatus = '')
OR
(@PCStatus like '%ON-HOLD%')
AND CAST(emp.EffectiveDate AS DATE) <= CAST(GETDATE() AS DATE)))
edited Nov 15 '18 at 5:24
answered Nov 15 '18 at 5:11
fa06fa06
16.7k21018
16.7k21018
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
add a comment |
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
This could work however it only applies on a string csv. If I apply this on a wide variety of integer csv, the result will differ.
– Elijah Elcano
Nov 15 '18 at 14:33
add a comment |
So with the help of my colleague, we created a function that splits the csv into a temporary table and there I can simply check if a certain value is in the temporary table and return a Boolean for it. Thanks for the help guys.
if you are usingSQL Server 2016
or later you can useSTRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993
– Squirrel
Nov 16 '18 at 3:29
add a comment |
So with the help of my colleague, we created a function that splits the csv into a temporary table and there I can simply check if a certain value is in the temporary table and return a Boolean for it. Thanks for the help guys.
if you are usingSQL Server 2016
or later you can useSTRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993
– Squirrel
Nov 16 '18 at 3:29
add a comment |
So with the help of my colleague, we created a function that splits the csv into a temporary table and there I can simply check if a certain value is in the temporary table and return a Boolean for it. Thanks for the help guys.
So with the help of my colleague, we created a function that splits the csv into a temporary table and there I can simply check if a certain value is in the temporary table and return a Boolean for it. Thanks for the help guys.
edited Nov 16 '18 at 3:19
answered Nov 15 '18 at 14:37
Elijah ElcanoElijah Elcano
103
103
if you are usingSQL Server 2016
or later you can useSTRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993
– Squirrel
Nov 16 '18 at 3:29
add a comment |
if you are usingSQL Server 2016
or later you can useSTRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993
– Squirrel
Nov 16 '18 at 3:29
if you are using
SQL Server 2016
or later you can use STRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993– Squirrel
Nov 16 '18 at 3:29
if you are using
SQL Server 2016
or later you can use STRING_SPLIT()
. If not, this is the best around sqlservercentral.com/articles/Tally+Table/72993– Squirrel
Nov 16 '18 at 3:29
add a comment |
If you have mix AND
and OR
conditions, it is best to use parenthesis ( )
on it to clearly define the intended conditions.
Also avoid applying function on the column as it will prohibit the use of index on the column. If the EffectiveDate does not contain time, you may simply use equal emp.EffectiveDate = CAST(GETDATE() AS DATE)
else you should use >= today
and < tomorrow
DECLARE @PCStatus as varchar(50);
SELECT *
FROM Employee emp
WHERE
(
emp.PCStatus = @PCStatus
)
OR
(
@PCStatus = ''
)
OR
(
@PCStatus LIKE '%ON-HOLD%'
AND emp.EffectiveDate >= CAST(GETDATE() AS DATE)
AND emp.EffectiveDate < CAST(DATEADD(DAY, 1, GETDATE()) AS DATE)
)
EDIT : change to LIKE '%ON-HOLD%'
EDIT 2 : @PCStatus is CSV
here, the query is using STRING_SPLIT()
if you are using earlier version of SQL Server, use the DelimitedSplit8K
that i posted in the comments
DECLARE @PCStatus as varchar(50) = 'ACTIVE,ON-HOLD';
SELECT *
FROM Employee emp
WHERE
(
@PCStatus = ''
OR EXISTS
(
select *
from STRING_SPLIT(@PCStatus, ',') x
where x.value = emp.PCStatus
)
)
AND
(
emp.PCStatus <> 'ON-HOLD'
OR emp.EffectiveDate <= CAST(GETDATE() AS DATE)
)
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want
– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
add a comment |
If you have mix AND
and OR
conditions, it is best to use parenthesis ( )
on it to clearly define the intended conditions.
Also avoid applying function on the column as it will prohibit the use of index on the column. If the EffectiveDate does not contain time, you may simply use equal emp.EffectiveDate = CAST(GETDATE() AS DATE)
else you should use >= today
and < tomorrow
DECLARE @PCStatus as varchar(50);
SELECT *
FROM Employee emp
WHERE
(
emp.PCStatus = @PCStatus
)
OR
(
@PCStatus = ''
)
OR
(
@PCStatus LIKE '%ON-HOLD%'
AND emp.EffectiveDate >= CAST(GETDATE() AS DATE)
AND emp.EffectiveDate < CAST(DATEADD(DAY, 1, GETDATE()) AS DATE)
)
EDIT : change to LIKE '%ON-HOLD%'
EDIT 2 : @PCStatus is CSV
here, the query is using STRING_SPLIT()
if you are using earlier version of SQL Server, use the DelimitedSplit8K
that i posted in the comments
DECLARE @PCStatus as varchar(50) = 'ACTIVE,ON-HOLD';
SELECT *
FROM Employee emp
WHERE
(
@PCStatus = ''
OR EXISTS
(
select *
from STRING_SPLIT(@PCStatus, ',') x
where x.value = emp.PCStatus
)
)
AND
(
emp.PCStatus <> 'ON-HOLD'
OR emp.EffectiveDate <= CAST(GETDATE() AS DATE)
)
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want
– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
add a comment |
If you have mix AND
and OR
conditions, it is best to use parenthesis ( )
on it to clearly define the intended conditions.
Also avoid applying function on the column as it will prohibit the use of index on the column. If the EffectiveDate does not contain time, you may simply use equal emp.EffectiveDate = CAST(GETDATE() AS DATE)
else you should use >= today
and < tomorrow
DECLARE @PCStatus as varchar(50);
SELECT *
FROM Employee emp
WHERE
(
emp.PCStatus = @PCStatus
)
OR
(
@PCStatus = ''
)
OR
(
@PCStatus LIKE '%ON-HOLD%'
AND emp.EffectiveDate >= CAST(GETDATE() AS DATE)
AND emp.EffectiveDate < CAST(DATEADD(DAY, 1, GETDATE()) AS DATE)
)
EDIT : change to LIKE '%ON-HOLD%'
EDIT 2 : @PCStatus is CSV
here, the query is using STRING_SPLIT()
if you are using earlier version of SQL Server, use the DelimitedSplit8K
that i posted in the comments
DECLARE @PCStatus as varchar(50) = 'ACTIVE,ON-HOLD';
SELECT *
FROM Employee emp
WHERE
(
@PCStatus = ''
OR EXISTS
(
select *
from STRING_SPLIT(@PCStatus, ',') x
where x.value = emp.PCStatus
)
)
AND
(
emp.PCStatus <> 'ON-HOLD'
OR emp.EffectiveDate <= CAST(GETDATE() AS DATE)
)
If you have mix AND
and OR
conditions, it is best to use parenthesis ( )
on it to clearly define the intended conditions.
Also avoid applying function on the column as it will prohibit the use of index on the column. If the EffectiveDate does not contain time, you may simply use equal emp.EffectiveDate = CAST(GETDATE() AS DATE)
else you should use >= today
and < tomorrow
DECLARE @PCStatus as varchar(50);
SELECT *
FROM Employee emp
WHERE
(
emp.PCStatus = @PCStatus
)
OR
(
@PCStatus = ''
)
OR
(
@PCStatus LIKE '%ON-HOLD%'
AND emp.EffectiveDate >= CAST(GETDATE() AS DATE)
AND emp.EffectiveDate < CAST(DATEADD(DAY, 1, GETDATE()) AS DATE)
)
EDIT : change to LIKE '%ON-HOLD%'
EDIT 2 : @PCStatus is CSV
here, the query is using STRING_SPLIT()
if you are using earlier version of SQL Server, use the DelimitedSplit8K
that i posted in the comments
DECLARE @PCStatus as varchar(50) = 'ACTIVE,ON-HOLD';
SELECT *
FROM Employee emp
WHERE
(
@PCStatus = ''
OR EXISTS
(
select *
from STRING_SPLIT(@PCStatus, ',') x
where x.value = emp.PCStatus
)
)
AND
(
emp.PCStatus <> 'ON-HOLD'
OR emp.EffectiveDate <= CAST(GETDATE() AS DATE)
)
edited Nov 16 '18 at 3:36
answered Nov 15 '18 at 5:56
SquirrelSquirrel
11.9k22128
11.9k22128
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want
– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
add a comment |
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want
– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
Thanks for pointing it out. However this didn't provide any answer in identifying if the parameter holds the "ON-HOLD" value.
– Elijah Elcano
Nov 15 '18 at 14:35
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want– Squirrel
Nov 16 '18 at 1:12
@PCStatus
is a CSV ? or single value ? Please provide some sample data and expected result. Else we can only guess what you want– Squirrel
Nov 16 '18 at 1:12
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
We'll i thought that the structure of my query gives away that PCStatus is a csv. "ON-HOLD, ACTIVE, SUSPENDED" are the possible values of PCStatus and yes they can be submitted altogether or without the other.
– Elijah Elcano
Nov 16 '18 at 3:19
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312789%2fcheck-if-a-certain-value-exist-in-the-passed-parameter-in-query-sql-server%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
since you are using
IN
I suspect the@PCStatusas
is a comma separated string. If so, yourIN
clause isn't going to work. You'll need to use a string splitter or better yet, a table values parameter– scsimon
Nov 15 '18 at 5:18
can you please verify and re-format your query properly. Example is it suppose to be
@PCStatusas
orDECLARE @PCStatus as varchar(50);
?– Squirrel
Nov 15 '18 at 5:30