Viewing 15 posts - 991 through 1,005 (of 7,608 total)
No, adding a COMMIT will not speed it up, the associated explicit BEGIN TRAN will likely slow it down slightly. SQL will (auto)commit after the statement finishes anyway.
Be sure you...
February 8, 2022 at 10:52 pm
You have an explicit transaction called from within BEGIN TRY/END TRY yet the ROLLBACK (which presumably corresponds to the transaction) is in the CATCH block. Checking XACT_STATE in the...
February 7, 2022 at 4:43 pm
You need to step back and do proper data modeling on all your entities. That is the most important step in proper design.
Then, as you convert the entities to physical...
February 7, 2022 at 4:41 pm
SQL Server does not all "FROM @FILENAME", only "FROM 'data_file_name'". Google the syntax of the command.
You'll need to use dynamic SQL if you want to feed in a FROM file...
February 2, 2022 at 11:29 pm
I'm guessing you don't already have a row_num.
;WITH cte_add_row_num AS (
SELECT *, ROW_NUMBER() OVER(PARTITION BY ID ORDER BY DATE DESC) AS row_num
...
February 1, 2022 at 5:39 pm
Would need to see the tables' DDL and the actual query plan. Can't troubleshoot air.
February 1, 2022 at 1:02 am
Yeah, really should have mentioned that Pervasive thing to begin with :-). That means there are multiple rows being returned for each lookup. Which one you get will be random,...
January 31, 2022 at 9:06 pm
Another possibility is a bit shorter, uses only LIKE instead of LIKE and the LEN() function, and does the same thing is...
IIF(D.Zip LIKE '[0-9][0-9][0-9][0-9][0-9]', d.Zip,...
January 31, 2022 at 6:37 pm
--...
ALTER DATABASE [DBNameToRestoreHere] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [DBNameToRestoreHere]...
January 31, 2022 at 4:41 pm
I say don't use IIF. It's a completely foreign coding approach to other SQL. And there's no genuine need for it, since CASE can do the same thing, and IIF...
January 31, 2022 at 4:15 pm
If you want to rely on the existing zip always being fully padded on the left with zeros, you can do this:
CASE WHEN LEN(D.Zip) = 5 AND...
January 28, 2022 at 10:04 pm
You could probably use TRIGGER_NESTLEVEL to do that.
I tend to use session context values instead, set via sys.sp_set_session_context and SESSION_CONTEXT(N'<key_name>'). If you want more info on this...
January 28, 2022 at 8:21 pm
Don't use functions in a WHERE clause, that's a very bad habit. Yes, SQL Server now generally covers for you with dates/datetimes, but not always, there are some...
January 27, 2022 at 9:00 pm
'19 Nov 2022' is converts to the datetime value of '19 Nov 2022 00:00:00.000', which is earlier (less than) '19 Nov 2022 15:19:12.000'.
Try:
WHERE [...]
AND CONVERT(date, TransferredDate)...
January 27, 2022 at 7:13 pm
And the view did not exist before the proc was called and still did not exist after it was called?
If so, put the SQL in a variable and print it...
January 27, 2022 at 6:44 pm
Viewing 15 posts - 991 through 1,005 (of 7,608 total)