Tag Info

Hot answers tagged

10

Each row has a minimum of 7 bytes of overhead when stored in FixedVar format (the default). There will also be a (typically relatively small) number of pages used for the upper levels of the clustered index. Optimally stored, and disregarding the upper index levels, 2 million rows would require just over: (7 + 8 bytes) * 2,000,000 = 28.61MB. More ...


7

Try: where exists (select * .... where Customers.orderId = ... or Customers.secondaryId = ... ) Eg, if you were planning on: where orderId in (select value from ...) or secondaryorderid in (select value from ...) Then you make it so that you only call your subquery once, and build your OR clause into it. where exists (select * ...


3

There is no Run As proxy for T-SQL Job steps in SQL Server Agent. You could upvote this with the chance that one day it will be filled: https://connect.microsoft.com/SQLServer/feedback/details/632955/enable-sql-agent-proxies-to-run-t-sql-job-steps The current way to get a T-SQL command to run with a proxy is to run it as an Operating System Command ...


3

Could I through indexing alone influence SQL server to run this much faster. Possibly. There are all sorts of things you could try with indexing, including creating a filtered index to exclude the 95% of UserPasswordRequestHash entries that are null, expanding existing indexes to include more columns, or adjusting indexes so the chances of finding the ...


2

As kin mentioned above. The easist way seems to be bcp out and in. Script out your table to a file ( The create table script ) Run the following command Export Data at command line using bcp "Database.Schema.Table" out "D:\filename.dat" -N -S "SQLServer\Instance" -T Once you copy that file / move to other system create the table you need then do the ...


2

Does the ALTER DATABASE XYZ SET RECOVERY FULL imply that you are normally running in SIMPLE recovery model? If so, the logs from the SIMPLE mode period are discarded once they are no longer needed. There is no time machine to go back and recover the logs that were not saved. So, to interpret your script: ALTER DATABASE XYZ SET RECOVERY FULL; -- Begin ...


1

Put EXECUTE AS ... at the start of your script, to impersonate the appropriate login.


1

Why not use a Common Table Expression aka with clause? It's designed for exactly this purpose (among others). with orderIds as ( select orderId from ... ) select * from Customers where orderId in (select orderId from orderIds) or secondaryOrderId in (select orderId from orderIds); See ...


1

You query should probably be rewritten as an exists instead of an in See this link for more examples. Your query would then look something along the lines of select * from Customers C where exists (select 'x' from ordertable o where c.orderid = o.orderid) or exists (select 'x' from ordertable o where c.secondaryOrderId = o.orderid) If both subqueries ...



Only top voted, non community-wiki answers of a minimum length are eligible