« first day (1774 days earlier)      last day (2544 days later) » 
05:00 - 20:0020:00 - 22:00

5:27 AM
rachel, we're not around on weekends. -_-
Morning guys.
 
6:16 AM
@war can you give me important points of topics i should look upto? which are not available in tutorials.
 
 
2 hours later…
8:11 AM
morning guys, @ARr0w
 
8:59 AM
morning guys
 
9:13 AM
hey @AndyK
 
sup man?
 
ah all good once my brain wakes up
you?
 
lol
feeling like a spring today
 
haha so you rested over the weekend then?
 
 
2 hours later…
10:58 AM
morning guys
 
hey @TonyPeterson
 
how do I indicate that I want to rollback a transaction if an error occurs. I've got my BEGIN TRANSACTION statement at the start of the SP.
 
like this?
try
begin
...
end
catch
begin
rollback
end
 
so basically the same as in c# with a try catch?
 
I assume so but then I don't know C#...yet mwahahahahaha!
 
11:05 AM
c# does try {...} catch() and finally
 
oh yeah cool, don't think SQL has finally though
 
I don't think I need finally
I just realize this morning that if one update fails I want them all rolled back. I saw some transaction code in the C# this is replacing.
 
yeah, there's a company called RedGate that is all about migration scripts for DBs
so i've been looking at their stuff
transactions seem the only way :)
 
cool
The current database I'm using has data going back to 1999, everything from 1999 to 2013 was all migrated from an old Sybase db to Sql Server.
 
wow...don't you love the way that business seems to love data hoarding?
"do you actually need to data from 1999?" "no." "so can I get rid of it?" "...eh....no"
 
11:11 AM
yeah, a lot of the old data is pretty crufty. And yeah, its way beyond the limit of what needed for accounting purposes. There's some weird receipts in there that must have been tests
 
@TonyPeterson wow, fun times
 
There was an old application that ran that database and was 16-bit, so when we went to 64 bit pcs, we had to replace the db and application.
 
but keep ALL the data
 
sigh well at least you'll be busy @TonyPeterson
 
11:14 AM
I've been writing the replacement application for years. It's in use, but they still want more features. And I was pretty unexperienced when I started working on the replacement, so I'm coming back now and trying to clean things up.
 
@TonyPeterson Fair play!
 
Right now I'm isolating the part that Voids checks, but it's going to be replaced with a few validations and then this new SP, and that's it.
 
11:46 AM
Hi all
 
440 lines of C# code deleted. I'd say that's a success, still gotta test it.
Hey @Alex
 
Hey Tony
 
hey @Alex
 
Hey Shaneis
 
hey guys
sorry @Shaneis. Could not answer that much
first day of the intern
he is asking intern's questions
 
11:52 AM
no worries @AndyK, I think I know how busy you are
hey sweet, an intern!
that should help eventually
 
yeah
he should
let's see how it goes
definitely not stupid
asking the correct questions
hi @Alex , hi @TonyPeterson
 
Hey @AndyK
 
sup man?
 
Not much, just testing a sp
that saved a ton of C# code :)
 
cool
lol
excellent
 
11:54 AM
Hi Andy
 
hey man
lunch is over. going back to the grind. catch you in a bit
 
It's interesting how much LINQ code is needed to just generate a LEFT JOIN on a couple of tables
 
yeah it seems like a paid to do left joins in LINQ
 
You have to use GroupJoin and SelectMany, with some incredibly gnarly syntax
 
I like LINQ for working with just LINQ to Objects more than for dealing with actually databases now
 
12:02 PM
@TonyPeterson boo! :)
 
For simple stuff, LINQ is great. It gets interesting with more complex queries. Then a sproc comes in handy
Though it's still fun to get LINQ to do the complex stuff too :)
 
I use dapper dot net a lot lately, and just pull into typed objects with SQL queries
I've done a lot of calculations and computations that used to take many loops in C# with a few LINQ to objects commandsa
 
Hmm. Dapper dot net. goes off on Google to search
 
It's a set of extension methods for the DbConnection interface.
conn.Execute("VoidCheckProcedure", new { checkID = origCheck.Check_ID }, commandType: CommandType.StoredProcedure);
that's using dapper dot net. No need to get a data reader or do a while read, it just dumps it into typed objects
 
Nice
 
12:05 PM
well this is an execute but I use it with queries all the time too. But if you search for just Dapper you get something else ;)
char ostatus = conn.Query<char>("SELECT [Status] FROM [Check] WHERE CheckID = @checkID", new { checkID = origCheck.Check_ID })
you create a new anon type with the names of the parameters as names in the anon type to pass parameters
 
Their page says it's also very performant
 
It's a very simple layer over SQL, but I use it whenever I would otherwise just right SQL normally. I haven't used it enough to notice the performance differences, but I believe them.
 
12:46 PM
I'm running into problems with this sp, so I started debugging it, and SSMS tells me Unable to Step. Invalid Operation. When I step over BEGIN TRY
nevermind I was trying to step into it. I was able to step over that line
 
1:24 PM
I'm declaring a cursor, opening it, and then cursor status immediately shows -3 status in the debugger. For some reason it's not recognizing it as a cursor, even though the FETCH_NEXT works fine. It errors out at the CLOSE command.
 
@TonyPeterson I would advise not to use a cursor but if you want to show the bare bones of the code, I'll take a look
 
The problem, is I'm inserting rows into a table that has an auto incremented ID, but I need to use that ID field to insert into another table. I don't know how to do that with pure sql style.
I'll send a gist of my code
gist: VoidCheckProcedure SP errors on Close cursor, 2017-03-27 13:31:26Z
ALTER PROCEDURE VoidCheckProcedure
@checkID int
AS
BEGIN
	BEGIN TRANSACTION;

		BEGIN TRY

			/* update status of Orig Check to V */
			UPDATE [Check] SET [Status] = 'V' WHERE Check_ID = @checkID;

			/* update PayableChecks on Check to inactive */
			UPDATE PayableCheck SET Active = 0
			WHERE CheckID = @checkID;

			/* update payables on Check to status O */
			UPDATE p SET [Status] = 'O'
			FROM Payable p
			INNER JOIN PayableCheck pc ON pc.PayableID = p.PayableID
			WHERE pc.CheckID = @checkID;

			/* update errors on Check to status O */
			UPDATE Error SET [Status] = 'O'
			FROM Error
			INNER JOIN Payable on Error.ErrorID = Payable.ErrorID
			INNER JOIN PayableCheck on Payable.PayableID = PayableCheck.PayableID
			WHERE PayableCheck.CheckID = @checkID

			/* update Receipts on Check to O, X, or V */
			UPDATE r1
			SET [Status] =
				CASE 
					WHEN MaxSeq.MaxSeqNo % 2 = 1 THEN			-- ends in a void
						CASE r1.SequenceNo
							WHEN MaxSeq.MaxSeqNo THEN 'V'
							WHEN MaxSeq.MaxSeqNo - 1 THEN 'V'
							ELSE 'X'
						END
					WHEN MaxSeq.MaxSeqNo % 2 = 0 THEN
						CASE r1.SequenceNo
							WHEN MaxSeq.MaxSeqNo THEN 'O'
							ELSE 'X'
						END
				END
			FROM Receipt r1
			INNER JOIN Payable on r1.TransactionKey = Payable.ReceiptTKey
			INNER JOIN PayableCheck ON Payable.PayableID = PayableCheck.PayableID
			INNER JOIN
			(
				SELECT r2.Receipt_ID, MAX(r2.SequenceNo) as MaxSeqNo
				FROM Receipt r2
				GROUP BY Receipt_ID
			) MaxSeq ON r1.Receipt_ID = MaxSeq.Receipt_ID
			WHERE PayableCheck.CheckID = @checkID

			/* Insert offset Check */
			INSERT INTO [Check] 
			(Check_Number, Check_Date, Check_Cleared, Grower_ID, [Status], Amount)
			SELECT c.Check_Number, GETDATE(), 'P', c.Grower_ID, 'V', -c.Amount
			FROM [Check] c
			WHERE c.Check_ID = @checkID

			/* Insert offset Errors */

			DECLARE @growerID varchar(20)
			DECLARE @amount decimal(19,2)

			DECLARE error_cursor CURSOR FOR
				SELECT GrowerID, Amount FROM Error WHERE CheckID = @checkID;
			OPEN error_cursor;
			FETCH NEXT FROM error_cursor INTO @growerID, @amount;

			WHILE @@FETCH_STATUS = 0
			BEGIN
				/* Insert offset Errors */
				INSERT INTO Error
				(CheckID, GrowerID, Amount, [Status], ErrorDate)
				VALUES
				(@checkID, @growerID, -@amount, 'V', GETDATE())

				/* Insert offset Payables */
				INSERT INTO Payable
				(GrowerID, Amount, ErrorID, [Status])
				VALUES
				(@growerID, -@amount, SCOPE_IDENTITY(), 'V')
		 
				FETCH NEXT FROM error_cursor INTO @growerID, @amount
			END

			CLOSE error_cursor;
			DEALLOCATE error_cursor;
		END TRY

	BEGIN CATCH
		PRINT ERROR_MESSAGE()
		ROLLBACK TRANSACTION
	END CATCH;

	IF @@TRANCOUNT > 0
		COMMIT TRANSACTION;
END
Its in the insert offset errors section
 
Couple of ways to get the last identity value: stackoverflow.com/a/42655/177416
But preferred way is the OUTPUT clause of INSERT
 
that's only the last one though. I need to insert 1 Error table record for each Error record that matches the pattern and then 1 payable record for each of those, that is linked to the new ErrorIDs that were auto-created.
I'll look into the Output clause idea
I hate using cursors, and I know very little about them, so I hear you on that one
 
I wonder if you could store the output values in a temp table then insert those into the other table
 
1:40 PM
I thought about that, but I thought I ran into a problem with that approach. Maybe I'll give it another shot
I think I didn't know about how to insert the keys into the table, so putting those two together should work.
Thanks Alex
I just did it directly into the other table. We'll see if it works:

INSERT INTO Error
OUTPUT inserted.GrowerID, inserted.Amount, inserted.ErrorID, inserted.[Status]
INTO Payable
SELECT CheckID, GrowerID, Amount, [Status], ErrorDate
FROM Error
WHERE Check_ID = @checkID
 
You're welcome
 
Hi everyone
 
1:57 PM
Hello
It didn't work going directly into the other table, but it looks like a temp table approach works
 
Nice!
I often declare a table variable for this stuff
Then you can stuff it full of whatever you want
 
DECLARE @einserts TABLE (
growerID varchar(20),
amount decimal(19,2),
errorID int,
[status] char(1));


INSERT INTO Error
(CheckID, GrowerID, Amount, [Status], ErrorDate)
OUTPUT inserted.GrowerID, inserted.Amount, inserted.ErrorID, inserted.[Status]
INTO @einserts
SELECT CheckID, GrowerID, Amount, [Status], ErrorDate
FROM Error
WHERE CheckID = @checkID

INSERT INTO Payable
(GrowerID, Amount, ErrorID, [Status])
SELECT growerID, amount, errorId, [status]
FROM @einserts
 
^ yep that
Not sure why I didn't use #temp tables too much, variables instead
 
I've used variables mostly as well
 
Some issue with the #temp stuff. Can't remember what
 
2:00 PM
never used OUTPUT before though. I use SCOPE_IDENTITY a lot. I have SPs to insert a row and return the key.
Finally got it to commit successfully :)
 
:)
Yeah, used SCOPE_IDENTITY for earlier SQL versions; but OUTPUT is the recommended way for 2008+
 
yes it looks like a better way
 
Nice, I go for coffee and you guys figure it out :)
 
2:18 PM
You snooze, you lose :D
 
@Alex I got coffee so I wouldn't snooze!!!
 
Hehehe!
I do the same with tea here
 
Tea!!! you have stronger willpower to stay awake than I do!
 
It feels like it should be lunchtime but its only 10am here.
I was using the wrong check Id but I got that fixed, and it seems to all be working right now.
 
@Shaneis I never know which one has more caffeine. Some folks say coffee, others say tea
 
2:24 PM
depends on what you get I guess
 
Would just own a packet of that for the packaging alone!
 
had it once, didn't sleep for a whole night...wasn't tired either
scary
 
I find coffee is too much for me. I can handle tea
 
I have coffee in the morning, if I have too much coffee or soda later in the day I can't sleep
 
With tea, I stop the caffeinated variety by around 2. Then have decaf
 
2:38 PM
yeah I try to stop around 4pm as well
 
 
2 hours later…
4:15 PM
heading off, tty guys
 
Hello
 
4:33 PM
See ya, Shaneis
Hi
 
4:44 PM
@alex
Do you know if there's a way to insert a list of static values inner joined with a table?
 
Hmm
Yeah, something like this...
INSERT INTO MyTable (Col1, Col2, Col3)
	SELECT 'SomeStaticValue', 'AnotherStaticValue', t2.someColumn
		FROM Table1 t1 join Table2 t2 on t1.someOtherColumn = t2.anotherColumn
		WHERE ....
Static values can be anything static, not just strings
 
5:02 PM
Yeah I'm familiar with that one, but this is a table of static values
So something like this:
INSERT INTO @users (name, ID)
VALUES
('Arnold'),('Harry'),('Elizabeth'),('Marry')
JOIN Users u
ON name = u.name
 
Oh
 
The only thing I can think of doing is inserting into a temp table with Name and ID as null
 
Take a look into this: stackoverflow.com/a/20404789/177416
 
Then updating the table with the join values
 
Nah, you shouldn't have to
INSERT INTO table3 ( name, age, sex, city, id, number, nationality)
SELECT name, age, sex, city, p.id, number, n.nationality
FROM table1 p
INNER JOIN table2 c ON c.Id = p.Id
That from the SO answer
 
5:07 PM
That wouldn't work either unfortunately
Well I mean that's how I'm doing it right now
First I insert all the static values in a @tempTable
 
INSERT INTO @users (name, ID)
SELECT 'Arnold','Harry','Elizabeth','Marry'
FROM Table1 t1 JOIN Users u
ON t1.name = u.name
Oh, you need a UNION, I think
 
That wouldn't work
 
You want a record for each name?
 
Ahh
I've done that
 
5:10 PM
But a union means a bunch of superfluous inner joins
I think the only way is to insert the static values into a temp table
 
INSERT INTO @users (name, ID)
SELECT 'Arnold'
FROM Table1 t1 JOIN Users u
ON t1.name = u.name

UNION
SELECT 'Harry'
FROM Table1 t1 JOIN Users u
ON t1.name = u.name

UNION
SELECT 'Elizabeth'
FROM Table1 t1 JOIN Users u
ON t1.name = u.name

UNION
SELECT 'Marry'
FROM Table1 t1 JOIN Users u
ON t1.name = u.name
 
But I have +1100 static values
 
Ahhhh
 
I think the only way to do it is to first insert the static values into a temp table
 
Why do you need the JOIN? Is it providing something
 
5:12 PM
Then inner join that table with the Users table and update that table
It's providing the IDs
 
OK. Let's see
Create a subquery where you select all the names as static values
 
What do you mean?
 
INSERT INTO @users (name, ID)
SELECT t1.Name, t2.Somethingelse
FROM
(SELECT Name, Id
	FROM Users) t1 join Table2 t2 on t1.Name = t2.Name
Something like that
 
But the static values aren't in a table
 
Where do they come from?
 
5:16 PM
I have a word document that I need to insert the values from
 
Woof
Can you pull them out and store them on a table for the query, then delete the table?
 
Basically what I do is create a temp table @newUsers (name, age, package, etc.) and insert all the static values from the word file into that temp table
 
Then you've got a table you can use to join with
 
Then I do an inner join with the Users table on the name, and update the null userID column
Basically, I was wondering if that could be done in one step
 
Thinking you're doing it right this way, in two steps
Otherwise you'd be trying to populate one temp table from the Word doc while populating the other table with the JOIN
 
5:34 PM
Yeah I was hopeful though lol
That's all right
 
6:04 PM
@JamieLester By the way, just because I didn't know a way doesn't mean there's no way to do it :)
You could post a question on SO and see what you get
 
Haha true, but I wasn't quite sure how to explain it
I like asking in chat since I can immediately clarify if there's confusion
 
You did a good job explaining. Just say you've got two temp tables and how they need to get populated, provide some pseudocode if needed
 
6:23 PM
ok I'll do that then
 
Feel free to post a link to it here
 
@Alex you've got such an amazing patience when explaining things. I need to learn from you
 
Thanks, nah, you've got to see the other friends in this room. They're the models you should follow :)
Shaneis, Andy, Tony, ARr0w, War
 
6:39 PM
me ?
thanks (blush)
 
:)
 
user7480455
Hi all can I ask a question about the Error: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. stored procedure
 
user7480455
?
 
@007 What's your code look like?
 
user7480455
Hi Alex... I will show it
 
user7480455
6:50 PM
It's a stored procedure
 
user7480455
ALTER PROCEDURE [dbo].[vrs_Check_Avaliablity]
@req_ID INT,
@frmDay DATETIME,
@thrDay DATETIME,
@poolnum VARCHAR(50)
AS

SET NOCOUNT ON

SELECT * FROM vrs_RequestsInfo WHERE
(CONVERT(DATETIME, @frmDay) >= CONVERT(DATETIME, [From]) AND CONVERT(DATETIME, @frmDay) <= CONVERT(DATETIME, thru)
OR CONVERT(DATETIME, @thrDay) >= CONVERT(DATETIME, [From]) AND CONVERT(DATETIME, @thrDay) <= CONVERT(DATETIME, thru)
OR CONVERT(DATETIME, @frmDay) >= CONVERT(DATETIME, [From]) AND CONVERT(DATETIME, @thrDay) <= CONVERT(DATETIME, thru)
 
user7480455
it's odd because when I test the procedure I the error stating that it's line 20
 
user7480455
which in this case that would be @frmDay DATETIME,
 
Can you do a test call in Management Studio? What do you pass @frmDay?
 
user7480455
but the error is triggered by the value that gets passed to the poolnum
 
user7480455
6:53 PM
yeah
 
user7480455
its very ood
 
user7480455
My test
 
user7480455
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[vrs_Check_Avaliablity]
@req_ID = 4593,
@frmDay = '04/07/2017 09:00 AM' ,
@thrDay = '04/07/2017 07:00 PM' ,
@poolnum = N'P-15915'

SELECT 'Return Value' = @return_value

GO
 
user7480455
if I take the dash out of 'P-15915'
 
user7480455
it runs
 
user7480455
6:54 PM
if I put in an invalid date it fails as it should
 
user7480455
but it's odd that the P- seems to be causing the error
 
So in Management Studio, the above EXEC runs okay, or fails?
 
user7480455
the above fails
 
user7480455
if I use p15915 it works
 
Is Pool_No alphanumeric?
 
user7480455
6:56 PM
yes sir
 
Try hardcoding those values into the sproc's SELECT and run it
What do you get?
 
user7480455
it works
 
user7480455
when I do that
 
With the dash?
 
user7480455
yes sir
 
user7480455
6:58 PM
it's so very odd
 
user7480455
I also tried changing the dates to datetime2
 
Try using @poolnum = ['P-15915']
 
user7480455
ok
 
user7480455
so I m taking away this: @poolnum = N'P-15915'
 
user7480455
and replacing that with what you type with no CAP N right?
 
user7480455
7:05 PM
USE [VRS]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[vrs_Check_Avaliablity]
@req_ID = 4593,
@frmDay = '04/07/2017 09:00 AM' ,
@thrDay = '04/07/2017 07:00 PM' ,
@poolnum = ['P-15915']

SELECT 'Return Value' = @return_value

GO
 
user7480455
this worked
 
user7480455
what are the brackets? What do they mean?
 
So it returns the correct results?
 
@007
 
user7480455
yes
 
7:06 PM
It's because N'text' is NVARCHAR
 
user7480455
It did
 
But @poolnum is only VARCHAR
 
Yep
 
user7480455
Hi jamie... so is that a bug in the microsoft sql
 
user7480455
because in the procedure we have @poolnum VARCHAR(50)
 
7:07 PM
No you're passing NVarchar to Varchar
 
So @poolnum VARCHAR = 'P-15915' will work or @poolnum NVARCHAR = N'P-15915' will work
 
Try to take off the N from before the value
 
VARCHAR isn't the same as NVARCHAR
 
Try this: @poolnum = 'P-15915'
 
user7480455
@poolnum = 'P-15915' this fails
 
7:08 PM
What's the error message?
 
Ahh
 
user7480455
this app as been arounf for like 5 years and today is the first time this has happened... even though this guy gets run all the time... what could have changed...
 
user7480455
?
 
user7480455
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. stored procedure
 
user7480455
is the error
 
7:10 PM
Hmmm perhaps the stored procedure needs to be recompiled
 
user7480455
is there a command for that? Or do I just rewrite it
 
So if you pass the N'.... to the stored proc, it returns that error? If you use the [] fixes it?
 
user7480455
Sql is not my strong area
 
user7480455
yes sir alex
 
Nah, when you save the stored proc, the next time you run it, it's compiled
Or actually, it's compiled on save
 
user7480455
7:11 PM
ok because I ttried changing datetime to datetime2 so I gues I recompiled it
 
Because it will throw compilation errors
 
user7480455
this is just too odd
 
I'd recommend using the brackets for now
 
user7480455
did the kids at microsoft roll out an update or something?
 
Not sure, or something about the data changed
 
7:12 PM
Hmmm
 
user7480455
how would I add those to the stored proc or would I need to add them to the call
 
user7480455
from the appl;ication
 
Try running the body of the stored procedure and declare the parameters at the top
 
user7480455
with like concat or something
 
Try calling it with the brackets, concat them onto it
 
user7480455
7:14 PM
ok Alex and jamie
 
user7480455
are you saying change this @req_ID INT,
@frmDay DATETIME,
@thrDay DATETIME,
@poolnum VARCHAR(50)
 
user7480455
to declear vs params?
 
Just to see if that will work
 
user7480455
so I just type declear up there?
 
Like DECLARE @poolnum VARCHAR(50) = 'P-15915'
See if that throws an error
 
user7480455
7:15 PM
ahh ok
 
user7480455
hmmm it did not like that
 
user7480455
Must declare the scalar variable "@poolnum".
 
user7480455
DECLARE @poolnum VARCHAR(50) = 'P-15915'
 
user7480455
what cause the the exec to show the cap N automatically by the way?
 
Try:
DECLARE @poolnum VARCHAR(50)
SET @poolnum = 'P-15915'
The should definitely work
 
user7480455
7:27 PM
ahh oo
 
Did that work
 
user7480455
sadly no... I must have the syntax wrong
 
user7480455
ALTER PROCEDURE [dbo].[vrs_Check_Avaliablity]
@req_ID INT,
@frmDay DATETIME,
@thrDay DATETIME

DECLARE @poolnum VARCHAR(50)

SET @poolnum ='P-15915'
AS

SET NOCOUNT ON
 
user7480455
is that setup correctly?
 
user7480455
I get the following errors
 
user7480455
7:29 PM
Msg 156, Level 15, State 1, Procedure vrs_Check_Avaliablity, Line 16
Incorrect syntax near the keyword 'DECLARE'.
Msg 156, Level 15, State 1, Procedure vrs_Check_Avaliablity, Line 19
Incorrect syntax near the keyword 'AS'.
Msg 137, Level 15, State 2, Procedure vrs_Check_Avaliablity, Line 25
Must declare the scalar variable "@thrDay"
 
Oh no sorry
I meant just run it separately
You'll want to switch the procedure back to how it was
 
user7480455
I did
 
user7480455
so I guess I was not clear on your meaning
 
user7480455
sorry I only know the very basics of SQL
 
Not to worry
Show me again what the stored procedure looks like again?
 
user7480455
7:32 PM
Sure thing
 
user7480455
USE [VRS]
GO
/****** Object: StoredProcedure [dbo].[vrs_Check_Avaliablity] Script Date: 3/27/2017 2:47:47 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO




-- =============================================
-- Author: Praisy Kuriakose
-- Create date: <Create Date,,>
-- Description: Double check the status of the vehicle when manager's approval
-- =============================================

ALTER PROCEDURE [dbo].[vrs_Check_Avaliablity]
@req_ID INT,
@frmDay DATETIME,
@thrDay DATETIME,
 
And when you run that, does it work?
 
user7480455
not it only works when I remove the dash or put the [] the poolnum as asked of me by Alex
 
user7480455
not= no*
 
Rather when you run the ALTER PROCEDURE statement (the one you posted just now) does it give an error?
 
user7480455
7:34 PM
no
 
user7480455
it updates just fine
 
And what do you type to execute the procedure?
 
user7480455
the application calls it via a Sqlhelper.ExecuteDataset
 
user7480455
in sql studio I call it by right clicking execute
 
user7480455
and it brings up a window for me to enter params
 
7:39 PM
What happens when you run:

EXEC vrs_Check_Avaliablity 4593, getdate(), getdate(), 'P-15915'
 
user7480455
I will give that a try
 
user7480455
Incorrect syntax near ')'.\
 
user7480455
it does ont like the getdate()
 
user7480455
not
 
ok try:
EXEC vrs_Check_Avaliablity 4593, '04/07/2017 09:00 AM', '04/07/2017 07:00 PM', 'P-15915'
 
user7480455
7:43 PM
ok trying
 
user7480455
Msg 242, Level 16, State 3, Procedure vrs_Check_Avaliablity, Line 20
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.
 
Oh my goodness lol I think I know what it is
Maybe not
 
user7480455
oh
 
user7480455
lol
 
What if you changed @frmDay @thrDay to VARCHAR(100)?
 
user7480455
7:46 PM
ok I will
 
user7480455
dang... I get the same error
 
Wait...
Nevermind
 
user7480455
Ass I mention to alex... this code has been running great up until recent days
 
user7480455
as
 
user7480455
sorry as
 
user7480455
7:48 PM
its so very wacky
 
Yeah very strange
Sorry I wasn't much help
 
user7480455
No you were very helpful
 
user7480455
I learned alot about trouble shooting
 
user7480455
in this case trouble is shooting back... but I am learning something
 
user7480455
I appreciate your help alot! I will just hard code the brackets alex told me about and go with that
 
7:50 PM
Without being there to try it out, I'm afraid I won't be much more help
 
user7480455
Alex... many thanks to you aswell
 
user7480455
its ok... I thank you for your time...
 
But I can't imagine that would work since the brackets are outside the string
Hopefully it works
 
user7480455
yeah I don;t know... it also works when I remove the dash
 
user7480455
thanks again
 
7:52 PM
What is you change @poolnum to NVARCHAR(50)?
What if*
 
user7480455
I will give it a try and see
 
user7480455
I still get the error... and the exce code looks like this:
 
user7480455
USE [VRS]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[vrs_Check_Avaliablity]
@req_ID = 4593,
@frmDay = N'04/07/2017 09:00 AM',
@thrDay = N'04/07/2017 07:00 PM',
@poolnum = N'P-15915'

SELECT 'Return Value' = @return_value

GO
 
Does the error give a line number?
 
user7480455
yes.. line 20
 
7:56 PM
oooh
 
user7480455
which is @frmDay DATETIME,
 
user7480455
in the stored proc
 
SELECT * FROM vrs_RequestsInfo WHERE Pool_No = 'P-15915'
 
user7480455
Yes that works
 
user7480455
Did each param in the view
 
user7480455
7:58 PM
as vrs_RequestsInfo is a view
 
user7480455
the view is a bit complex... may I share that
 
05:00 - 20:0020:00 - 22:00

« first day (1774 days earlier)      last day (2544 days later) »