Viewing 15 posts - 121 through 135 (of 7,191 total)
Mick
I'm afraid it does matter. Windowing functions were introduced in SQL Server 2012 (I should have noticed which forum you posted in). You'll need to use ROW_NUMBER to number the...
March 30, 2020 at 3:22 pm
Mick
This is the logic you need.:
SELECT
dateofReading
,Electricity
,Gas
,Electricity - LAG(Electricity,1,Electricity) OVER (ORDER BY dateofReading) AS ElecUsage
,Gas - LAG(Gas,1,Gas) OVER (ORDER BY dateofReading) AS GasUsage
FROM testtable;
However, if you try to...
March 30, 2020 at 3:05 pm
Why wouldn't you just disable the login?
Might still need server-level access, for example to create logins or linked servers.
John
March 25, 2020 at 9:03 am
Just revoke all permissions on all databases? And make sure that it doesn't have any server-level access (eg sysadmin) that overrides that.
John
March 24, 2020 at 8:48 am
Yes, I think a Windows scheduled task (if that's what it's called these days) would be your best bet. I'm sure you don't need me to tell you this, but...
March 18, 2020 at 3:26 pm
Changing the collation of a database is difficult, because, as you've already seen, you have to change the collation of each character-based column as well. And it's not as simple...
March 18, 2020 at 10:31 am
Do you have a column that defines the order of those rows? If not, how do you know to subtract Pierre's number before Jacques's? I think you want to do...
March 13, 2020 at 4:16 pm
Don't install a SQL Server failover cluster - just a normal SQL Server instance on each Windows cluster node. Then create your AG, your listeners and so on. There'll be...
March 13, 2020 at 2:12 pm
If you're going to generate an artificial primary key, then why not go all the way and use an identity column or GUID? It would be much more efficient.
To generate...
March 13, 2020 at 9:55 am
Query sysjobsteps to get the SQL statements. Join to sysjobs to get the name of the jobs.
John
March 13, 2020 at 9:08 am
One at a time, making sure you're always patching a server that isn't hosting the AG. You don't have to do them all on the same day, although it's best...
March 12, 2020 at 2:32 pm
The Data Migration Adviser (I think that's what it's called) is what you need. If your application uses ad hoc SQL instead of (or in addition to) stored procedures, you'll...
March 9, 2020 at 1:33 pm
Yes, that would be better. Thanks Phil.
John
March 5, 2020 at 3:28 pm
Something like this, which isn't very efficient. Better to stored your dates as dates if that's an option.
WHERE DATEADD(MONTH,12,CAST(CAST(data AS char(8)) AS date)) < GETDATE()
John
March 5, 2020 at 3:01 pm
No, I'm afraid don't. Are you sure it's linked to the SQL Audit thing, or could it be just a coincidence? Did you run sp_whoisactive or something like that during...
March 4, 2020 at 9:26 am
Viewing 15 posts - 121 through 135 (of 7,191 total)