Viewing 15 posts - 1,051 through 1,065 (of 7,613 total)
Instead of using a CASE expression (as you were trying) - or stacked OR's: WHERE @mDepth > iif(@tDepth = 0, -1, @tDepth)
Consider: @mDepth >= 0 is equivalent to @mDepth...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 14, 2022 at 8:12 pm
The values go into the variables at the top.
You'll note that I declared the variables first, then SET them all together. I personally think it's much more confusing to mix...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 14, 2022 at 8:10 pm
Verify that variable @CopyFromUser includes a valid value.
Add a PRINT statement in the script. Existing code:
...
From dbo.Operator
Where Operator_Ref = @CopyFromUser
SET @rowcount = @@ROWCOUNT
...
so that you can verify how many INSERTs...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 14, 2022 at 6:07 pm
CASE is an expression not a statement. That means that the result of WHEN or THEN must be a single value. No operators (>,>=, etc.) and no keywords can be...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 14, 2022 at 5:03 pm
I executed the script on an instance with 100s of dbs and it worked fine. Of course I got the "No insertions made..." message since I didn't have dbs named...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 14, 2022 at 4:45 pm
I presume you want to know why, when running under the DP300User1 context, the SP works but the query on it's own does not.
When a SP is created by...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 13, 2022 at 9:35 pm
DECLARE @CopyUser varchar(30)
DECLARE @Dbnames varchar(8000)
DECLARE @Sql varchar(8000)
DECLARE @UserOp varchar(30)
SET @Dbnames = 'DB1,DB2,DB3' --<<--!!set these values before running!!--<<--
SET @CopyUser = 'User1' --<<--!!set these values before running!!--<<--
SET @UserOp =...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 13, 2022 at 9:22 pm
You should never shrink a database, only shrink a file(s).
It seems as if you have one gigantic data file (very bad idea, btw, you should use multiple data files, but...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 13, 2022 at 5:34 pm
You must use the max memory setting when you put more than one instance of SQL on a given box, for the reasons others have stated above.
And, for that many...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2022 at 4:22 pm
CONCAT is not a safe way to do this because different values could appear to be the same.
Do all the columns have to match? Or just some?
For now,...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2022 at 4:09 pm
You shouldn't use 'n/a' as a "value" in place of NULL. Effectively you're corrupting the data. You should just use NULL itself instead.
If all readers of the table...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2022 at 4:06 pm
That is not advisable as this will always start the job, even when it is disabled !
My point is: When a sysadmin or "sqlagent job manager" disables a job...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 10, 2022 at 3:37 pm
I'm almost certain there's a more efficient way to do this, but I can't think of it now.
;WITH cte_valid_first_dose AS (
SELECT *
...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 7, 2022 at 11:42 pm
SELECT
US.UID,
CASE WHEN COUNT(UD.UID) > 0 THEN 'YES' ELSE 'NO' END AS [UID Loaded],
CASE...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 6, 2022 at 11:15 pm
You can start the job easily from the trigger using:
EXEC msdb.dbo.sp_start_job @job_name = '<your_job_name_here>'
That will just start the job and immediately return to the trigger (that is, I'm confirming that...
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 6, 2022 at 4:26 pm
Viewing 15 posts - 1,051 through 1,065 (of 7,613 total)