Hi,
I am getting error because of this line in stored procedure.How to enclose string value.
Count(Case When Totalhours<='25:0' Then EmpNo end) as Less.
25:0 is varchar datatype so i am enclosing in quotations. -
-
ALTER PROCEDURE [dbo].[SAR_Sp_GetScheduledHours](@date1 DATETIME, @date2 DATETIME, @date3 DATETIME, @date4 DATETIME)
-
AS
-
DECLARE @query VARCHAR(MAX)
-
BEGIN
-
SET @query = 'SELECT '+ CHAR(39) + 'Forecasted HC as per Hiring Plan' + CHAR(39) + ' AS HeadCount, [' + CONVERT(VARCHAR,@date1,101) + '], [' + CONVERT(VARCHAR,@date2,101)+ '], [' + CONVERT(VARCHAR,@date3,101) + '], [' + CONVERT(VARCHAR,@date4,101) + ']' +
-
'FROM
-
(SELECT WeekStartDate,
-
Count(Case When Totalhours<='25:0' Then EmpNo end) as Less
-
FROM TestTable1 group by WeekStartDate)
-
AS SourceTable
-
PIVOT
-
(
-
max(Less)
-
FOR WeekStartDate IN (' + '[' + CONVERT(VARCHAR,@date1,101) + '], [' + CONVERT(VARCHAR,@date2,101)+ '], [' + CONVERT(VARCHAR,@date3,101) + '], [' + CONVERT(VARCHAR,@date4,101) + ']' + ')
-
) AS PivotTable'
-
EXEC(@query)
-
END
1 1223
This question is better suited for a database expert.
What database management system are you using?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
Does anyone have any suggestions on a way to automate sending an
Access pivot (query) using VBA Access and Outlook?
|
by: maneeshkhare |
last post by:
I am trying to update a field in Access db (.mdb) via a DataSet using
the following code. I am continously getting this error:
Has anybody seen this before?
1. If I try using the same code for...
|
by: Tore Halset |
last post by:
Hello.
I am trying to port an old java application from MS SQL Server to
PostgreSQL running on Mac OS X. I have access to the java source code
and can make modifications. I have tried with...
|
by: tyngtyng |
last post by:
hi...
i'm new to the php and now i'm getting an error to insert my data inside the form..and also undefined index in latest_updated......
Now,i'm having trouble catching what i'm doing...
|
by: chitara |
last post by:
is there any posibility to block mysql port or someting?
I am getting "Error ,query failed" during adding any data through the admin panel of that website:-(
same softwares(php, mysql and IIS)...
|
by: mrityunjay11 |
last post by:
Error
SQL query:
CREATE TABLE per(
item_name varchar,
item_number int,
payment_status int,
payment_amount int,
payment_currency int
);
|
by: srinivasan2009 |
last post by:
Hi,
While Running macro i am getting error in a particular query "Numeric field overflow"
For which i am opening that query and just saving the query. and query is starts executing..
...
|
by: rajesh0303 |
last post by:
Query gives error : Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
Query is :
select...
|
by: Pradeep23 |
last post by:
There are three computers A,B and C
A is Manager' computer in which Data is stored as File System
B is my desktop having SQL Server 2005
C is Main SQL Server 2005.
B is able to connect to C....
|
by: NareshN |
last post by:
Hi,
I am getting error in following stored procedure in where condition Must declare the scalar variable "@CampaignId".I already declared CampaignId but still getting error.Please see where...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |