[{"content":"We run ProxySQL on Kubernetes in front of MySQL, across several clusters. PMM 3 already monitors the MySQL servers. This is how we added the ProxySQL layer to it, and what to watch out for.\nThe pod Three containers, two shared volumes:\nContainer Does fetch-secrets (init) Logs into Azure Key Vault, writes every secret to /secrets/env.secret, downloads a CA bundle proxysql-server Sources env.secret, renders proxysql.cnf with envsubst, starts ProxySQL pmm-client (sidecar) Starts pmm-agent, registers with the PMM server, adds ProxySQL on 127.0.0.1:6032 Key management We keep no credentials in Kubernetes Secrets or in Git. Everything comes from Key Vault at pod start, through the init container, using the pod\u0026rsquo;s workload identity:\n1 2 3 4 5 6 7 8 9 10 11 PROXY_ADMIN_PWD=$(az keyvault secret show --vault-name \u0026#34;$VAULT\u0026#34; --name \u0026#34;$ADMIN_PWD_SECRET\u0026#34; --query value -o tsv) PMM_SERVICE_TOKEN=$(az keyvault secret show --vault-name \u0026#34;$VAULT\u0026#34; --name \u0026#34;$PMM_TOKEN_SECRET\u0026#34; --query value -o tsv) # ProxySQL stats user for PMM: random, per pod, never stored anywhere PROXYSQL_PMM_MONITOR_PWD=$(LC_ALL=C tr -dc \u0026#39;A-Za-z0-9\u0026#39; \u0026lt; /dev/urandom | head -c 32) cat \u0026gt; /secrets/env.secret \u0026lt;\u0026lt;EOF PROXY_ADMIN_PWD=$PROXY_ADMIN_PWD PMM_SERVICE_TOKEN=$PMM_SERVICE_TOKEN PROXYSQL_PMM_MONITOR_PWD=$PROXYSQL_PMM_MONITOR_PWD EOF Three rules that came out of it:\nThe PMM token is a Grafana service-account token, and it has to be Admin. Registering a node and adding a service are inventory writes, and PMM\u0026rsquo;s role matrix reserves those for Admin; the client install docs say the same. There is no narrower role for agents. So the token is treated as what it is: one per PMM server, an expiry date, stored only in Key Vault, read only by the init container, and rotated by updating the vault and rolling the pods. The vault secret is named after the PMM server, not the environment, so a cluster can be pointed at a different backend config without also being handed the wrong PMM token. The ProxySQL side needs no stored secret at all. The stats password is generated per pod and rendered into the config: stats_credentials=\u0026quot;pmm:${PROXYSQL_PMM_MONITOR_PWD};\u0026quot;. It only grants read access to the stats schema on the admin port. The CA bundle comes from the init container too. The percona/pmm-client:3 image we pulled had no CA trust store at all. The sidecar 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 - name: pmm-client image: our-registry/pmm-client:3-ca # percona/pmm-client:3 + ca-certificates, tag pinned env: - name: NODE_NAME valueFrom: { fieldRef: { fieldPath: spec.nodeName } } - name: POD_NAMESPACE valueFrom: { fieldRef: { fieldPath: metadata.namespace } } command: [\u0026#34;/bin/sh\u0026#34;, \u0026#34;-c\u0026#34;] args: - | export SSL_CERT_FILE=/secrets/ca-bundle.crt source /secrets/env.secret pmm-agent --config-file=${PMM_AGENT_CONFIG_FILE} \u0026amp; until curl -s http://127.0.0.1:7777/local/Status \u0026gt;/dev/null; do sleep 1; done # stable identity: \u0026lt;namespace\u0026gt;-\u0026lt;service\u0026gt;-\u0026lt;node\u0026gt;, not the pod name PMM_NAME=\u0026#34;${POD_NAMESPACE}-proxysql-${NODE_NAME}\u0026#34; pmm-admin config --force \\ --server-url=\u0026#34;https://service_token:${PMM_SERVICE_TOKEN}@${PMM_SERVER}\u0026#34; \\ \u0026#34;${NODE_NAME}\u0026#34; container \u0026#34;${PMM_NAME}\u0026#34; pmm-admin add proxysql --username=pmm --password=\u0026#34;${PROXYSQL_PMM_MONITOR_PWD}\u0026#34; \\ --service-name=\u0026#34;${PMM_NAME}\u0026#34; --host=127.0.0.1 --port=6032 wait Cleanup: don\u0026rsquo;t register by pod name The first version used ${HOSTNAME}-proxysql, the pod name. Every rollout replaces every pod, every new pod is a new node and a new service in PMM, and the old ones stay behind. After a few rollouts one cluster had 3 pods and 17 ProxySQL services in the inventory, and every dashboard drop-down was full of series that each covered one rollout window.\nThe fix is above: name the registration after the Kubernetes node the pod runs on, which survives the pod. pmm-admin config --force with the same node name replaces the previous pod\u0026rsquo;s registration (node, services, agents) instead of adding one — that is what the flag is for: \u0026ldquo;remove Node with that name with all dependent Services and Agents if one exist\u0026rdquo;. Removing an inventory entry does not delete the time series already stored, so history is kept and one continuous series per node shows up in the dashboards.\nThe namespace and service name are in the string because more than one ProxySQL flavour may run on the same node. If your node names carry a long generated pool suffix, shorten them in the script — the name only has to be stable.\nThis works because we schedule ProxySQL with node taints and tolerations so that exactly one ProxySQL pod lands on each node — the node is therefore a stable identity. If your pods can share a node or move between nodes, the node name is not enough. Either use a StatefulSet and its ordinal pod name (proxysql-0, proxysql-1, …) with the same --force pattern, or keep pod-named registrations and add a preStop hook that runs pmm-admin remove proxysql \u0026lt;name\u0026gt; so a pod cleans up after itself.\nOld pod-named entries have to be removed once. The Inventory page does it (Nodes tab, tick them, Delete, Force mode), or the API:\n1 2 3 # list nodes, then delete the stale ones with their services and agents curl -s -H \u0026#34;Authorization: Bearer $TOKEN\u0026#34; https://$PMM/v1/inventory/nodes | jq \u0026#39;.container[] | {node_id, node_name}\u0026#39; curl -s -X DELETE -H \u0026#34;Authorization: Bearer $TOKEN\u0026#34; \u0026#34;https://$PMM/v1/inventory/nodes/$NODE_ID?force=true\u0026#34; After that the only thing that leaves a ghost is a Kubernetes node being replaced — one entry, rarely.\nWhat broke on the way Four things, in the order they surfaced. Each one only became visible after the previous one was fixed.\npmm-admin config has no --server-username / --server-password. Those flags belong to pmm-agent setup (and its PMM_AGENT_SERVER_USERNAME / PMM_AGENT_SERVER_PASSWORD variables). With pmm-admin config the credentials go in the URL: https://service_token:$TOKEN@host. envsubst only substitutes exported variables. The stats password was sourced but not exported, so the config rendered as stats_credentials=\u0026quot;pmm:;\u0026quot; and the sidecar failed with what looked like a wrong password. Registered ≠ monitored. The inventory was fine and the dashboards were empty. Metrics are shipped by vmagent, which pmm-agent starts as a child process; in our pods it did not inherit SSL_CERT_FILE, and the stock image has no CA store, so every push failed TLS. We build our own image with ca-certificates on top of percona/pmm-client:3. Editing the base pod template is a production rollout when auto-sync is on. Ours rolled every production pod on merge. No user-facing errors — ProxySQL\u0026rsquo;s connection pool reconnected and 5xx stayed at baseline — but measure it, don\u0026rsquo;t assume it, and consider turning auto-sync off for this kind of app in production. ","date":"2026-09-01T22:20:40-07:00","permalink":"/2026/09/01/pmm-monitoring-proxysql-kubernetes/","title":"How to add PMM monitoring to ProxySQL on Kubernetes"},{"content":"The worst production failures are not the loud ones. A crash loop pages you. A failed sync shows up red in the UI. What we hit last weekend did neither: Argo CD kept reporting Synced and Healthy for 313 Applications while absolutely nothing was being deployed to them — for 57 hours, across two clusters, with no error, no Application condition, and a CI pipeline that reported success the whole time.\nThe trigger was about as ordinary as it gets. Somebody registered a new cluster.\nThe symptom A developer asked why their change wasn\u0026rsquo;t live. The pipeline was green. argocd app wait --health --sync had returned success three hours earlier. The Application\u0026rsquo;s status said exactly what you\u0026rsquo;d want it to say:\n1 2 3 4 5 6 7 status: reconciledAt: \u0026#34;2026-08-29T10:40:36Z\u0026#34; # frozen, 57 hours earlier health: { status: Healthy } # stale sync: { status: Synced } # stale conditions: [] # nothing surfaced summary: images: [\u0026#34;registry.example/app:OLD\u0026#34;] # spec had requested NEW three hours ago That reconciledAt is the tell. Argo CD had not looked at this Application since a specific moment two days earlier — it had simply stopped, and kept publishing its last opinion as if it were current.\nThis is worse than an outage. An outage tells you it is happening. This told our automation everything was fine.\nFinding it Our setup: application-controller as a Deployment with 10 replicas, dynamicClusterDistribution: true, controller.sharding.algorithm: round-robin, 48 clusters, roughly 3,300 Applications. Argo CD v3.4.5, Helm chart 9.7.1.\nFour signals located the problem within about an hour:\n1. The clusters looked half-registered. argocd cluster list showed the two affected clusters with an empty connection state, applicationsCount: 0, and no cacheInfo.lastCacheSyncTime — while all 46 others were Successful with a fresh cache.\n2. They appeared in nobody\u0026rsquo;s logs. We grepped roughly 41,000 log lines over a 5-minute window across all ten controller pods. A cluster with 304 Applications should be mentioned constantly. It appeared zero times. Not an error about it — nothing.\n3. One replica was shouting into the void. A single pod logged, about 2.8 times per second:\n1 level=warning msg=\u0026#34;The cluster https://cluster-A.example:6443 has no assigned shard.\u0026#34; 4. Ownership didn\u0026rsquo;t add up. Extracting dest-name= from each pod\u0026rsquo;s logs and comparing against argocd-app-controller-shard-cm showed two clusters being processed by two replicas simultaneously, and our two orphans processed by none.\nMeanwhile every shard entry in the ConfigMap was heartbeating normally, and no pod had restarted — they were four to five days old. Nothing had crashed. The distribution had simply drifted apart in memory.\nWhy adding one cluster moves half the fleet Here is the part that surprised me, and the reason a single cluster registration is not a small event.\nRound-robin assigns a shard by position:\n1 shard = (index in sorted cluster list) % replicas The sort key is Cluster.ID. And in util/db/cluster.go, SecretToCluster sets:\n1 ID: string(s.UID) s.UID is the cluster Secret\u0026rsquo;s Kubernetes UID — a random UUID assigned at creation time. So the \u0026ldquo;sorted cluster list\u0026rdquo; is sorted by random identifiers, and a newly created cluster lands at an arbitrary position in it. Every cluster sorting after that position shifts by one index, and therefore changes shard.\nIn our case the fleet went from 47 to 48 clusters, and the new Secret\u0026rsquo;s UID placed it at index 21 of 48. That re-indexed 26 of the 47 existing clusters. Adding one cluster reassigned more than half the estate.\nThat alone is not a bug — the controllers are supposed to converge on the new distribution. What actually happened is that one replica applied the re-shuffle partially. Reconstructing the intended distribution from the Secret UIDs (a model that matched the post-restart ownership we observed for 14 of 14 spot-checked clusters), one shard should have changed like this:\nmembers of that shard before the add in-cluster, stg-1, stg-2, stg-3, stg-4 after the add in-cluster, stg-4, dev-1, cluster-A, cluster-B (Cluster names are anonymized; the labels carry no ordering — the real sort key is a random UID.)\nWhat the replica owning that shard was actually processing 57 hours later:\nin-cluster, stg-4 — unchanged, fine dev-1 — moved in, correctly picked up stg-1, stg-3 — moved away, still being processed here and by their new owner cluster-A, cluster-B — moved in, never picked up by anyone So it wasn\u0026rsquo;t a wholesale stale map. It was per-cluster and partial: one of three incoming clusters adopted, two dropped on the floor, two outgoing clusters never released.\nThe recovery, and why it isn\u0026rsquo;t a fix 1 kubectl -n argocd rollout restart deploy/argocd-application-controller Both clusters reconnected within 60 seconds. All 313 Applications reconciled within five minutes. The log spam stopped. Nothing else — credentials, network, RBAC, the shard ConfigMap — was touched.\nThat\u0026rsquo;s a satisfying fix for about ten minutes, until you realise what it means: the only thing that reliably rebuilds the distribution is process start. Init() — the one full re-derivation from an authoritative cluster list — runs exactly once per process. After that, the in-memory map is maintained purely by incremental events. If a replica ever misses one, nothing repairs it and nothing notices.\nUpstream: what I found in the code I filed issue #29476 with the reproduction and the evidence, then kept reading. In controller/sharding/cache.go, Update looked like this:\n1 2 3 4 sharding.Clusters[newCluster.Server] = newCluster if hasShardingUpdates(oldCluster, newCluster) { sharding.updateDistribution() } hasShardingUpdates returns false when ID, Server and Shard are all unchanged — which is exactly the old == new pair the cluster-secret informer delivers on its periodic resync. So if a cluster\u0026rsquo;s first appearance on a given replica arrives as an update rather than an add, it gets inserted into Clusters with no entry in Shards — and nothing ever repairs that.\nAdd has always guarded for this case with !ok ||. Update did not.\nTwo consequences, and the second one is nastier:\nFor index-based algorithms like round-robin, a replica whose Clusters map differs from its peers\u0026rsquo; by a single entry computes a different shard for every cluster sorting after that difference. One missed event desynchronises a whole tail of the fleet. A cluster missing from Shards isn\u0026rsquo;t merely unowned. IsManagedCluster falls back to clusterShard := 0, so it gets claimed by whichever replica happens to be shard 0 and rejected by every other replica — including its rightful owner. The fix PR #29477 gives Update the same guard Add already had:\n1 2 3 4 5 _, known := sharding.Clusters[newCluster.Server] sharding.Clusters[newCluster.Server] = newCluster if !known || hasShardingUpdates(oldCluster, newCluster) { sharding.updateDistribution() } Three lines. It restores an invariant every other mutator in that file already maintains: every cluster in Clusters has an entry in Shards.\nThe test runs two replicas over the same three clusters, where one replica sees an Add for the third cluster and the other sees only an Update. Without the fix it fails with both halves of the production symptom at once:\n1 2 3 4 Error: Not equal: expected: 1 actual: 2 Messages: cluster https://kubernetes.default.svc should be processed by exactly one shard Error: Not equal: expected: 1 actual: 0 Messages: cluster https://1.1.1.1 should be processed by exactly one shard One cluster processed twice, one processed by nobody — the same two failure modes we saw in production, reproduced in a unit test.\nThe PR is open at the time of writing, and deliberately does not close the issue. What I can prove is that this is one reachable way for a replica\u0026rsquo;s map to diverge, and that it\u0026rsquo;s a local invariant fix worth making on its own. What I can\u0026rsquo;t prove is that it was the specific path our incident took: the reconstruction came from a 120-second sample of each replica\u0026rsquo;s logs, and controller logs at that volume retain about seven minutes, so it can\u0026rsquo;t be re-verified after the fact. There are at least two other reachable divergence paths in the same area. Saying \u0026ldquo;this fixes it\u0026rdquo; would have been a nicer story and a worse bug report.\nWhat I\u0026rsquo;d tell you to do about it If you run Argo CD with more than one application-controller replica, three things are worth doing today:\nAlert on stale reconciliation, not just on sync status. reconciledAt drifting far past your timeout.reconciliation is the only signal that distinguishes \u0026ldquo;genuinely healthy\u0026rdquo; from \u0026ldquo;frozen and lying\u0026rdquo;. Nothing in the health or sync status will tell you.\nTreat has no assigned shard as a page, not a warning. In a correctly distributed fleet that line should never appear. Ours was emitting it 2.8 times a second for two and a half days and nobody was looking.\nReconcile ownership against the shard ConfigMap. Periodically compare which clusters each replica is actually processing against argocd-app-controller-shard-cm. Any cluster with zero owners — or two — is the failure, before it becomes an incident.\nAnd the uncomfortable one: your CI\u0026rsquo;s argocd app wait --health --sync is not proof of deployment. It is proof that Argo CD\u0026rsquo;s last recorded opinion was healthy. If you need proof that the new image is running, check the running image.\nArgo CD v3.4.5, Helm chart 9.7.1. The relevant file controller/sharding/cache.go is byte-identical at v3.4.4, v3.4.8 and v3.5.2, so this applies across the 3.4 and 3.5 lines. Issue: #29476 · PR: #29477.\n","date":"2026-08-31T21:00:00-07:00","permalink":"/2026/08/31/argocd-round-robin-sharding-orphaned-clusters/","title":"Argo CD said Synced and Healthy for 57 hours while nothing deployed"},{"content":"The last post here was in November 2021, announcing a PASS Data Community Summit session on running SQL Server on Kubernetes. Almost five years later, this is the first post from the blog\u0026rsquo;s new home.\nWhat changed The platform. Simon\u0026rsquo;s SQL lived on WordPress.com since March 2011. It now runs on Hugo with the Stack theme. The posts are Markdown files in a Git repository, and every push builds and deploys the site — which, for a DevOps person, is how a blog should have worked all along: write, commit, push, done.\nNothing was lost. All 140 posts from 2011–2021 were imported through the WordPress.com REST API, including images, slide decks and the comments people left over the years (they\u0026rsquo;re at the bottom of each post, marked as archived). Post URLs kept the same /yyyy/mm/dd/slug/ shape, so old links and search results still land where they should.\nCategories finally mean something. Every old post was filed under \u0026ldquo;Common\u0026rdquo;. They are now split into Performance \u0026amp; Tuning, High Availability, Backup \u0026amp; Recovery, Troubleshooting, T-SQL \u0026amp; Scripts, Administration \u0026amp; Tools, Containers \u0026amp; DevOps and Community \u0026amp; Talks. There is also a Talks page collecting every conference and user-group session in one place, and a proper search.\nMe. When the blog went quiet I had just moved from being a DBA at Visa to leading DevOps at Nowcom. Today I\u0026rsquo;m AVP of DevOps \u0026amp; DBA there, responsible for both the DevOps and DBA teams. The SQL Server work never went away — it just sits inside Kubernetes clusters, CI/CD pipelines and on-call rotations now.\nWhat\u0026rsquo;s coming The old posts were mostly short troubleshooting notes I wanted to be able to find again. That format still works, and I\u0026rsquo;ll keep it, but the topics will follow what I actually do these days:\nSQL Server on Kubernetes in production — what held up from the 2019–2021 talks, and what didn\u0026rsquo;t. Database CI/CD — schema deployments, DACPAC vs. migration-based approaches, and rollout safety at scale. Running a DevOps + DBA organization — on-call, reliability work, and where the two disciplines overlap. AI-assisted operations — where coding agents and LLM tooling genuinely help a database/platform team and where they don\u0026rsquo;t. If any of the old posts are broken after the move — a missing image, a mangled code block — please email me at simon@simonsql.com.\nThanks for reading. It\u0026rsquo;s good to be back.\n","date":"2026-08-30T08:00:00-07:00","permalink":"/2026/08/30/simons-sql-is-back-on-github-pages/","title":"Simon's SQL is back — now on Hugo"},{"content":"Title : Can SQL server run on Kuberentes?\nAll sessions\n","date":"2021-11-04T09:55:44-07:00","permalink":"/2021/11/04/pass-data-community-summit-2021-speaker/","title":"PASS Data Community Summit 2021 - Speaker"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 /*********************************************************************************************** **Object Name: AG_Monitor ** **Description: Check AG Status ** **Input Parameters: ** **Return Value: N/A ** **Return Result Set: AG Monitoring result ** **Creator: Simon Cho ** *************************************************************************************************/ --\u0026lt;ReplicaLevel\u0026gt; SELECT replica_server_name , d.role_desc , d.connected_state_desc , d.replica_id , d.role_desc --, endpoint_url --, availability_mode_desc --, failover_mode_desc --, session_timeout --, backup_priority --, secondary_role_allow_connections_desc AS Secondary_Readable , Pri_Check.pri_Status --, Pri_Check.Sec_Status --, Pri_Check.Sync_Status , d.operational_state_desc , d.recovery_health_desc , d.synchronization_health_desc AS Sync_Status , d.last_connect_error_description AS ErrorMsg , DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), GETDATE()), d.last_connect_error_timestamp) AS ErrorDateTime FROM sys.availability_replicas r OUTER APPLY ( SELECT 1 AS IsPrimary , c.ip_address AS listnerIP , c.state_desc AS listnerStatus , a.primary_recovery_health_desc AS pri_Status , a.secondary_recovery_health_desc AS Sec_Status , a.synchronization_health_desc AS Sync_Status FROM sys.dm_hadr_availability_group_states a JOIN sys.availability_group_listeners B ON A.group_id = B.group_id JOIN sys.availability_group_listener_ip_addresses c ON b.listener_id = c.listener_id WHERE primary_replica = r.replica_server_name ) Pri_Check JOIN sys.dm_hadr_availability_replica_states d ON r.replica_id = d.replica_id --WHERE d.role NOT IN (1,2) -- 1:Primary, 2:Secondary, 0:Resolving -- OR d.operational_state \u0026lt;\u0026gt; 2 --0 = Pending failover, 1 = Pending, 2 = Online, 3 = Offline, 4 = Failed, 5 = Failed, no quorum --OR d.recovery_health \u0026lt;\u0026gt; 1 --0:In progress. At least one joined database has a database state other than ONLINE ( database_state is not 0).1- Online. All the joined databases have a database state of ONLINE ( database_state is 0). --OR d.synchronization_health \u0026lt;\u0026gt;2 -- 0 = Not healthy. At least one joined database is in the NOT SYNCHRONIZING state. --\t-- 1 = Partially healthy. Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing. --\t-- 2= Healthy. All replicas are in the target synchronization state: synchronous-commit replicas are synchronized, and asynchronous-commit replicas are synchronizing. -- OR d.connected_state \u0026lt;\u0026gt; 1 --0 Disconnected. The response of an availability replica to the DISCONNECTED state depends on its role, as follows: --\t--\tOn the primary replica, if a secondary replica is disconnected, its secondary databases are marked as NOT SYNCHRONIZED on the primary replica, which waits for the secondary to reconnect. --\t--\tOn a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica. --\t-- 1 Connected -- OR d.last_connect_error_number IS NOT NULL --\u0026lt;DBLevel\u0026gt; SELECT r.replica_server_name , r.replica_id , DB_NAME(DRS.database_id) , DRS.is_primary_replica , drs.synchronization_state , drs.synchronization_state_desc , drs.synchronization_health_desc , drs.database_state_desc , drs.suspend_reason_desc --, drs.is_suspended --, DRS.suspend_reason_desc --, drs.suspend_reason , drs.last_sent_time , drs.last_received_time , drs.log_send_queue_size , drs.log_send_rate , drs.redo_queue_size , drs.redo_rate --, drcs.is_failover_ready --, drcs.is_pending_secondary_suspend --, drcs.recovery_lsn , DATEDIFF(ss, drs.last_sent_time, DRS.last_received_time) AS Last_Log_commit_Duration_sec FROM sys.availability_replicas r JOIN sys.dm_hadr_database_replica_states DRS ON r.replica_id = DRS.replica_id --WHERE r.replica_id =\u0026#39;E0CCAF57-F7B8-46D0-BDE4-0EDF1FECE310\u0026#39; WHERE drs.synchronization_state NOT IN (2) --WHERE 1=1 --and DB_NAME(DRS.database_id)=\u0026#39;abce\u0026#39; -- OR drs.synchronization_health \u0026lt;\u0026gt; 2 --OR DRS.is_suspended=1 --OR drs.suspend_reason IS NOT NULL --OR DATEDIFF(ss, drs.last_sent_time, DRS.last_received_time)\u0026gt;30 -- longer than 30 sec. /* \u0026lt;synchronization_state\u0026gt; 0 Not synchronizing. For a primary database, indicates that the database is not ready to synchronize its transaction log with the corresponding secondary databases. For a secondary database, indicates that the database has not started log synchronization because of a connection issue, is being suspended , or is going through transition states during startup or a role switch. 1 Synchronizing. For a primary database, indicates that the database is ready to accept a scan request from a secondary database. For a secondary database, indicates that active data movement is occurring for the database. 2 Synchronized. A primary database shows SYNCHRONIZED in place of SYNCHRONIZING. A synchronous-commit secondary database shows synchronized when the local cache says the database is failover ready and is synchronizing. 3 Reverting. Indicates the phase in the undo process when a secondary database is actively getting pages from the primary database.Caution noteCaution When a database on a secondary replica is in the REVERTING state, forcing failover to the secondary replica leaves the database in a state in which it cannot be started as a primary database. Either the database will need to reconnect as a secondary database, or you will need to apply new log records from a log backup. 4 Initializing. Indicates the phase of undo when the transaction log required for a secondary database to catch up to the undo LSN is being shipped and hardened on a secondary replica. Caution noteCaution When a database on a secondary replica is in the INITIALIZING state, forcing failover to the secondary replica leaves the database in a state in which it be started as a primary database. Either the database will need to reconnect as a secondary database, or you will need to apply new log records from a log backup. \u0026lt;database_state\u0026gt; 0 Not healthy. The synchronization_state of the database is 0 (NOT SYNCHRONIZING). 1 Partially healthy. A database on a synchronous-commit availability replica is considered partially healthy if synchronization_state is 1 (SYNCHRONIZING). 2 Healthy. A database on an synchronous-commit availability replica is considered healthy if synchronization_state is 2 (SYNCHRONIZED) , and a database on an asynchronous-commit availability replica is considered healthy if synchronization_state is 1 (SYNCHRONIZING). */ ","date":"2021-07-31T22:51:27-07:00","permalink":"/2021/07/31/ag-monitoring-query/","title":"AG Monitoring query"},{"content":"This is honor to speak at SQL PASS Summit 2019 Please come in the session at 11AM, 11/8 Fri. Room: 608\nHere are the detail information. https://www.pass.org/summit/2019/Learn/SessionDetails.aspx?sid=92365\nPresentation download is here. Git Repository : https://dev.azure.com/xcloudapp/_git/PASS2019\n10 years ago, DBAs typically maintained a few critical databases. These days, it’s not strange anymore that a DBA maintains several hundred databases. Without automation CICD pipeline, a DBA would be the bottleneck for the faster deployment. Industry pretty much required who has the ability to automation of database deployment and operation. This session will delivery the automation of database operation including deployment and design and architecture of environment.Prerequisites: Who has Database deployment experience.\nSimon Cho is one of the founders of SQLAngeles.com, which is a Los Angeles Korean Tech PASS community group. As a Local Group leader, he is a Microsoft SQL community speaker. He has presented many times at SQLSaturdays and to PASS Local Groups. In the past, he lead a database team and managed hundreds of SQL Servers and DWs on VM environment in the gaming industry in Nexon America. He moved his passion to VISA Inc, the largest credit card provider in the world, where he used database technology to build a strong solution and a secure environment, with new strategies and features to maintain thousands of SQL Servers. He has now joined the Nowcom Corp, as a Director of DevOps, where he leads the DevOps team and DBA team.\nGeneral Session (75 minutes):\nDatabase CICD (Continuous Integration and Deployment) DevOps Comments (archived from WordPress) Simon Cho · 2021-09-03\nDatabase CICD (Continuous Integration and Deployment) – Simon Cho\n","date":"2019-11-08T02:48:11-08:00","permalink":"/2019/11/08/pass-summit-2019-database-cicd-simon-cho/","title":"PASS Summit 2019 - Database CICD (Simon Cho)"},{"content":"Date : Apr 13 2019 Location : Golden West College, 15744 Goldenwest St, Orange County, California, 92647, United States\nPresentation file download here.\nSQLSaturday – Orange County\n","date":"2019-04-04T12:09:08-07:00","permalink":"/2019/04/04/stepbystep-sql-server-on-container-what-is-kubernetes-sql-saturday-4-13/","title":"[StepByStep] SQL Server on Container? What is Kubernetes? - SQL Saturday 4/13"},{"content":"https://sqlla.pass.org/?EventID=13089\nPresentation file download here\nWe will do another one at SQL Saturday.\n","date":"2019-04-04T12:04:55-07:00","permalink":"/2019/04/04/stepbystep-sql-server-on-container-what-is-kubernetes-sql-la/","title":"[StepByStep] SQL Server on Container? What is Kubernetes? - SQL LA"},{"content":"https://landscape.cncf.io\nClick to access landscape.pdf\n","date":"2019-03-25T22:03:18-07:00","permalink":"/2019/03/25/cnfc-landscape/","title":"CNFC Landscape"},{"content":"Thank you for joining the SQL Saturday #740 – Orange County meeting.\nHere is the Presentation file for “[StepbyStep] SQL server Index operation for beginner to expert”.\n","date":"2018-04-16T10:05:32-07:00","permalink":"/2018/04/16/sqlsaturday-740-orange-county-stepbystep-sql-server-index-operation-for-beginner-to-expert/","title":"SQLSaturday #740 - Orange County - [StepbyStep] SQL server Index operation for beginner to expert"},{"content":"https://docs.microsoft.com/en-us/sql/relational-databases/indexes/guidelines-for-online-index-operations\nInitial unique clustered index on a view is exclusive from Online Index operation.\nHowever, unique clustered index is very required for indexed view.\n","date":"2018-03-08T14:31:07-08:00","permalink":"/2018/03/08/indexed-view-cant-create-online-in-the-beginning/","title":"Indexed View can’t create online in the beginning."},{"content":"I uploaded the presentation file on SQL Sat website.\nPlease check the below link.\nhttp://www.sqlsaturday.com/696/Sessions/Schedule.aspx\n","date":"2018-02-11T10:06:11-08:00","permalink":"/2018/02/11/sql-saturday-696-redmond/","title":"SQL Saturday #696 - Redmond"},{"content":"A couple of cases for this error message.\nNetwork device hardware failure. Old Driver version SQL bug. Please check the latest patch. TCP Chimney setting and the SyncAttackProtect setting. AG listener or Endpoint port misconfiguration. Encryption/Decryption issue during data transit. SSL or TLS cipher mismatch AG endpoint encryption method discrepancy. During AG or Mirroring failover transit. Network packet loss due to any reason Firewall blocking for certain case. Jumbo frame or MTU size misconfiguration. Login Authentication issue. https://sqlperformance.com/2013/11/system-configuration/ag-connectivity\nhttps://blogs.msdn.microsoft.com/developingfordynamicsgp/2013/12/03/tcp-chimney-setting-and-sql-server-error-tcp-provider-an-existing-connection-was-forcibly-closed-by-the-remote-host/\nhttps://blogs.msdn.microsoft.com/docast/2017/07/27/sql-connectivity-troubleshooting-checklist/\nhttps://technet.microsoft.com/en-us/library/ms187005(v=sql.105).aspx\nhttps://documentation.red-gate.com/clone2/troubleshooting/installation-issues/an-existing-connection-was-forcibly-closed-by-the-remote-host-error\nhttp://sirsql.net/content/2016/11/09/availability-groups-issue-with-2016-cu2/\n","date":"2018-01-19T10:04:26-08:00","permalink":"/2018/01/19/an-existing-connection-was-forcibly-closed-by-the-remote-host/","title":"An existing connection was forcibly closed by the remote host"},{"content":"Finally, MS release new service pack update for SQL 2012 and SQL 2014.\nPlease follow the below link for guidance for SQL server.\nAll official links keep updating in the same article.\nSQL Server – https://support.microsoft.com/en-us/help/4073225/guidance-for-sql-server Windows Server – https://support.microsoft.com/en-us/help/4072698/windows-server-guidance-to-protect-against-the-speculative-execution\nHere is the recent update for SQL 2012 and SQL 2014.\n4057117 Description of the security update for SQL Server 2014 SP2 CU: January 16, 2018 4057120 Description of the security update for SQL Server 2014 SP2 GDR: January 16, 20184057116 Description of the security update for SQL Server 2012 SP4 GDR: January 12, 2018\nHere are all supported versions’ link.\nSQL Server 2017 GDR SQL Server 2016 SP1 CU7* SQL Server 2016 SP1 GDR SQL Server 2016 RTM CU SQL Server 2016 RTM GDR SQL Server 2008 SP4 SQL Server 2008 R2 SP3SQL Server 2012 SP4 GDR SQL Server 2012 SP3 CU SQL Server 2012 SP3 GDR SQL Server 2014 SP2 CU* SQL Server 2014 SP2 GDR\n","date":"2018-01-18T00:10:23-08:00","permalink":"/2018/01/18/meltdown-and-spectre-update-for-sql-2012-and-sql-2014/","title":"Meltdown and Spectre update for SQL 2012 and SQL 2014"},{"content":" It started from “Google Project Zero”.\nhttps://googleprojectzero.blogspot.com/\nVariants of this issue are known to affect many modern processors, including certain processors by Intel, AMD and ARM. For a few Intel and AMD CPU models, we have exploits that work against real software. We reported this issue to Intel, AMD and ARM on 2017-06-01.\nHere is the guide line for SQL Server and Windows Server.\nSQL Server – https://support.microsoft.com/en-us/help/4073225/guidance-for-sql-server Windows Server – https://support.microsoft.com/en-us/help/4072698/windows-server-guidance-to-protect-against-the-speculative-execution\nSQL Server Patch available for below version.\nSQL 2012 and SQL 2014 should release soon.\nSQL Server 2017 CU3* SQL Server 2017 GDR SQL Server 2016 SP1 CU7* SQL Server 2016 SP1 GDR SQL Server 2016 RTM CU SQL Server 2016 RTM GDR SQL Server 2008 SP4 (This is new version of SP4. Version number is slightly different.) SQL Server 2008 R2 SP3(This is new version of SP3. Version number is slightly different.)\nIt seems like not that many articles reported SQL 2008 SP4 and SQL Server 2008 R2 SP3 with this patch.\nhttps://www.brentozar.com/archive/2018/01/sql-server-patches-meltdown-spectre-attacks/\nMicrosoft SQL Server Updates for Meltdown and Spectre Exploits\nPerfermance\nhttps://cloudblogs.microsoft.com/microsoftsecure/2018/01/09/understanding-the-performance-impact-of-spectre-and-meltdown-mitigations-on-windows-systems/\nploited Vulnerability CVE Exploit Name Public Vulnerability Name Windows Changes Silicon Microcode Update ALSO Required on Host Spectre 2017-5753 Variant 1 Bounds Check Bypass Compiler change; recompiled binaries now part of Windows Updates Edge \u0026amp; IE11 hardened to prevent exploit from JavaScript No Spectre 2017-5715 Variant 2 Branch Target Injection Calling new CPU instructions to eliminate branch speculation in risky situations Yes Meltdown 2017-5754 Variant 3 Rogue Data Cache Load Isolate kernel and user mode page tables No In general, our experience is that Variant 1 and Variant 3 mitigations have minimal performance impact, while Variant 2 remediation, including OS and microcode, has a performance impact.\nWith Windows 10 on newer silicon (2016-era PCs with Skylake, Kabylake or newer CPU), benchmarks show single-digit slowdowns, but we don’t expect most users to notice a change because these percentages are reflected in milliseconds. With Windows 10 on older silicon (2015-era PCs with Haswell or older CPU), some benchmarks show more significant slowdowns, and we expect that some users will notice a decrease in system performance. With Windows 8 and Windows 7 on older silicon (2015-era PCs with Haswell or older CPU), we expect most users to notice a decrease in system performance. Windows Server on any silicon, especially in any IO-intensive application, shows a more significant performance impact when you enable the mitigations to isolate untrusted code within a Windows Server instance. This is why you want to be careful to evaluate the risk of untrusted code for each Windows Server instance, and balance the security versus performance tradeoff for your environment. ","date":"2018-01-10T18:11:27-08:00","permalink":"/2018/01/10/meltdown-and-spectre/","title":"Meltdown and Spectre"},{"content":"SQL Compression backup wasn’t work before SQL 2016.\n\u0026lt;SQL Server 2014 and below\u0026gt;\nhttps://msdn.microsoft.com/library/bb934049(SQL.120).aspx\nEncrypted data compresses significantly less than equivalent unencrypted data. If TDE is used to encrypt a database, backup compression will not be able to significantly compress the backup storage. Therefore, using TDE and backup compression together is not recommended.\n\u0026lt;After SQL server 2016 and above\u0026gt;\nIt could work with special command.!\nhttps://blogs.msdn.microsoft.com/sqlcat/2016/06/20/sqlsweet16-episode-1-backup-compression-for-tde-enabled-databases/\nIt is important to know that while backing up a TDE-enable database, the compression will kick in ONLY if MAXTRANSFERSIZE is specified in the BACKUP command. Moreover, the value of MAXTRANSFERSIZE must be greater than 65536 (64 KB). The minimum value of the MAXTRANSFERSIZE parameter is 65536, and if you specify MAXTRANSFERSIZE = 65536 in the BACKUP command, then compression will not kick in. It must be “greater than” 65536. In fact, 65537 will do just good. It is recommended that you determine your optimum MAXTRANSFERSIZE through testing, based on your workload and storage subsystem. The default value of MAXTRANSFERSIZE for most devices is 1 MB, however, if you rely on the default, and skip specifying MAXTRANSFERSIZE explicitly in your BACKUP command, compression will be skipped.\nPlease Note :\nUpdate April 6th, 2017\nWe have recently discovered some issues related to the use of TDE and backup compression in SQL Server 2016. While we fix them, here are some tips to help you avoid running into those known issues:\nCurrently it is not advisable to use striped backups with TDE and backup compression If your database has virtual log files (VLFs) larger than 4GB then do not use backup compression with TDE for your log backups. If you don’t know what a VLF is, start here. Avoid using WITH INIT for now when working with TDE and backup compression. Instead, for now you can use WITH FORMAT. ","date":"2018-01-10T17:45:23-08:00","permalink":"/2018/01/10/sql-compression-backup-with-tde/","title":"SQL Compression backup with TDE"},{"content":"Update statistics is known as online operation.\nDetail lock mode is in below blog.\nhttps://www.mssqltips.com/sqlservertip/4608/does-updating-sql-server-statistics-cause-blocking/\nHowever, update statistics could create seriouly blocking issue such as “SCH-M” in certain case.\nHere is detail lock mode in certain case.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 \u0026lt;Database name=\u0026#34;TEST\u0026#34;\u0026gt; \u0026lt;Locks\u0026gt; \u0026lt;Lock request_mode=\u0026#34;S\u0026#34; request_status=\u0026#34;GRANT\u0026#34; request_count=\u0026#34;1\u0026#34; /\u0026gt; \u0026lt;/Locks\u0026gt; \u0026lt;Objects\u0026gt; \u0026lt;Object name=\u0026#34;Tbl_cdc1\u0026#34; schema_name=\u0026#34;dbo\u0026#34;\u0026gt; \u0026lt;Locks\u0026gt; \u0026lt;Lock resource_type=\u0026#34;METADATA.INDEXSTATS\u0026#34; index_name=\u0026#34;PK_Tbl_cdc1\u0026#34; request_mode=\u0026#34;Sch-S\u0026#34; request_status=\u0026#34;GRANT\u0026#34; request_count=\u0026#34;2\u0026#34; /\u0026gt; \u0026lt;Lock resource_type=\u0026#34;METADATA.STATS\u0026#34; request_mode=\u0026#34;Sch-M\u0026#34; request_status=\u0026#34;CONVERT\u0026#34; request_count=\u0026#34;1\u0026#34; /\u0026gt; \u0026lt;Lock resource_type=\u0026#34;METADATA.STATS\u0026#34; request_mode=\u0026#34;Sch-S\u0026#34; request_status=\u0026#34;GRANT\u0026#34; request_count=\u0026#34;1\u0026#34; /\u0026gt; \u0026lt;Lock resource_type=\u0026#34;OBJECT\u0026#34; request_mode=\u0026#34;Sch-S\u0026#34; request_status=\u0026#34;GRANT\u0026#34; request_count=\u0026#34;2\u0026#34; /\u0026gt; \u0026lt;Lock resource_type=\u0026#34;OBJECT.UPDSTATS\u0026#34; request_mode=\u0026#34;X\u0026#34; request_status=\u0026#34;GRANT\u0026#34; request_count=\u0026#34;1\u0026#34; /\u0026gt; \u0026lt;/Locks\u0026gt; \u0026lt;/Object\u0026gt; \u0026lt;/Objects\u0026gt; \u0026lt;/Database\u0026gt; Please check that “request_mode=“Sch-M” request_status=”CONVERT“”.\nI’m currently investigating detail.\nI’ll share later in Part2.\nSimon\nUpdate statistics blocking issue(Part 1)\n","date":"2017-11-30T14:33:16-08:00","permalink":"/2017/11/30/update-statistics-blocking-issuepart-1/","title":"Update statistics blocking issue(Part 1)"},{"content":" 1 2 3 4 5 6 Get-WmiObject -namespace \u0026#34;root\\mscluster\u0026#34; -class MSCluster_Resource Get-WmiObject : Invalid namespace mofcomp C:\\Windows\\System32\\wbem\\ClusWMI.mof PS C:\\Windows\\system32\u0026gt; mofcomp C:\\Windows\\System32\\wbem\\ClusWMI.mof Microsoft (R) MOF Compiler Version 6.2.9200.16398 Copyright (c) Microsoft Corp. 1997-2006. All rights reserved. Parsing MOF file: C:\\Windows\\System32\\wbem\\ClusWMI.mof MOF file has been successfully parsed Storing data in the repository… Done!\nHere is for SQL Server WMI issue. Expected error message when WMI doesn’t registered properly.\n1 2 3 4 5 6 7 The following exception occurred while trying to enumerate the collection: \u0026#34;An exception occurred in SMO while trying to manage a service.\u0026#34;. At line:xx char:xxx + $wmi.xxxx + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : ExceptionInGetEnumerator Another error message when open SQL configuration manage.\nCannot connect to WMI provider. You do not have permission or the server is unreachable\nPlease check path and Version number in below script.\n1 2 3 4 5 6 7 8 9 10 11 //SQL 2008 mofcomp \u0026#34;%programfiles(x86)%\\Microsoft SQL Server\\100\\Shared\\sqlmgmproviderxpsp2up.mof\u0026#34; //SQL 2012 mofcomp \u0026#34;%programfiles(x86)%\\Microsoft SQL Server\\110\\Shared\\sqlmgmproviderxpsp2up.mof\u0026#34; //SQL 2014 mofcomp \u0026#34;%programfiles(x86)%\\Microsoft SQL Server\\120\\Shared\\sqlmgmproviderxpsp2up.mof\u0026#34; //SQL 2016 mofcomp \u0026#34;%programfiles(x86)%\\Microsoft SQL Server\\130\\Shared\\sqlmgmproviderxpsp2up.mof\u0026#34; //SQL 2017 mofcomp \u0026#34;%programfiles(x86)%\\Microsoft SQL Server\\140\\Shared\\sqlmgmproviderxpsp2up.mof\u0026#34; ","date":"2017-10-23T14:20:48-07:00","permalink":"/2017/10/23/wmi-broken-fci-or-sql/","title":"WMI broken FCI or SQL Server"},{"content":"https://www.linkedin.com/pulse/how-fix-sql-server-configuration-manager-cannot-connect-mohamed-fekry/\n","date":"2017-10-23T12:05:13-07:00","permalink":"/2017/10/23/cannot-connect-to-wmi-provider-you-do-not-have-permission-or-the-server-is-unreachable-note-that-you-can-only-manage-sql-server-2005-and-later-servers-with-sql-server-configuration-manager/","title":"Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager."},{"content":"Please download Presentation and Demo script.\nAuto DB deployment basic\n(Free DBA work from DB deployment, just put the click button to DevOps.)\n**SQL server Deployment /배포/패치/**점검 자동화 기초\n부제 – DBA 잠좀 자게 해주세요**. F5** 클릭은 컴터가 알아서\n아직도 DB 서버 배포를 손으로 하나요?\nSQL package 를 이용해서 수십대의 DB에 자동으로 빠르게 배포하는방법에 대해서 살펴보겠습니다.\n날짜\n06/21/2017 03:00~05:00 (UTC)\n06/21/2017 00:00~02:00 (EDT)\n06/21/2017 22:00~24:00 (CDT)\n06/20/2017 20:00 ~ 22:00 (PDT)\n06/21/2017 12:00 ~ 14:00 (KOR)\n장소 : 222 N Sepuveda Blvd, El Segundo, CA, 90245\n온라인 링크 : https://meet.lync.com/sqlpass365-sqlpass/sqlangeles/MMGM08Y1 (이어폰 준비)\n페에스북 라이브 방송 : https://www.facebook.com/sqlmvp (스터디 시간에 맞춰서 방송합니다.)\n카카오톡 오픈 채팅 : SQL Angeles 로 검색해서 채팅 참여 가능 합니다.\n주의 사항 : 스피커로 청취시 반드시 마이크는 음소거로 설정.\nSimon Cho\nDatabase Engineer\\DevOps Engineer\nVISA DBA\nSQL Saturday Speaker\nSQL Angeles Co-founder\nEmail : simon@simonsql.com\nBlog : https://simonsql.com/\nLinkedIn : https://www.linkedin.com/in/simonsql/\n[주차 안내]\n길건너 해빗 버거 주차 후 도보로 이동 (약 3분 거리)\n[Sponsored]\n","date":"2017-06-21T00:10:18-07:00","permalink":"/2017/06/21/auto-db-deployment-basic-sql-angeles/","title":"Auto DB Deployment basic - SQL Angeles"},{"content":"We are quickly approaching 6/10. http://www.sqlsaturday.com/640/eventhome.aspx\nTop 5 reasons why you have to attend SQL Saturday in LA event\nExcellent panel of 40+ Speakers:\n2 x Past PASS Presidents + 1 PASS Regional Mentor\n2 x Microsoft Certified Masters (MCM)\n5 x Microsoft Certified Trainers (MCT)\n6 x PASS Speakers\n7 x Microsoft Most Valuable Professionals (MVP)\n9 x Microsoft Certified Solutions Experts (MCSE)\n6 x Microsoft Certified Solutions Associate (MCSA) Free education – Please see schedule for more details\nFree food – we will have coffee, orange juice and pastries for breakfast; pizza, beverages and fresh fruit for lunch\nTwo beautiful venues with enough room for 300 attendees\nA chance to win great prizes\nP.S. One more reason to attend a SQL Saturday in LA – attend and get a FREE e-book by O’Reilly Media!\n","date":"2017-05-31T12:16:57-07:00","permalink":"/2017/05/31/sqlsaturday-in-los-angeles-610/","title":"SQLSaturday in Los Angeles 6/10"},{"content":"Today is the first day I visit the Microsoft Headquarters in Redmond.\nThank you for coming in SQL Saturday in Redmond.\nHere are my presentation file and the demo script.\nPresentation file\nDemo\n","date":"2017-04-15T22:18:15-07:00","permalink":"/2017/04/15/sql-saturday-613-redmond-presentation/","title":"SQL Saturday #613 - Redmond Presentation"},{"content":"Finally, I’ve completed my presentations at SQL Saturday – Orange County!\nThere were only 3 audiences when I did the 2nd presentation at Orange county 3 years ago.\nToday, I got full audiences.\nI really appreciated who came to my session and SQL Saturday.\nIt really encourages me and I get lots of comments from people.\nHere is the presentation file and Demo file.\nBuild ETL efficiently (10x) with Minimal Logging Presentation file is here. Myths and Truths about SQL Server Transaction Presentation file is here. Demo file is here. Thank you for attending.\nhttp://www.sqlsaturday.com/611/Sessions/Schedule.aspx\n","date":"2017-04-03T22:24:25-07:00","permalink":"/2017/04/03/sql-saturday-611-orange-county-presentation/","title":"SQL Saturday #611 - Orange County Presentation"},{"content":"https://docs.microsoft.com/en-us/sql/ssms/sql-server-management-studio-changelog-ssms\n","date":"2017-03-07T18:11:58-08:00","permalink":"/2017/03/07/ssms-2016-release-tracking/","title":"SSMS 2016 Release tracking"},{"content":"It’s really helpful in a very rare case.\nThe application name is case sensitive.\nnet start mssqlserver /m”Microsoft SQL Server Management Studio – Query”\nnet start mssqlserver /m”sqlcmd”\nhttps://msdn.microsoft.com/en-us/library/ms188236.aspx\n","date":"2017-03-06T16:59:31-08:00","permalink":"/2017/03/06/start-sql-server-in-single-user-mode/","title":"Start SQL Server in Single-User Mode"},{"content":"https://jongurgul.com/blog/tag/sysobjvalues/\n","date":"2017-02-23T17:51:48-08:00","permalink":"/2017/02/23/sys-sysobjvalues/","title":"sys.sysobjvalues"},{"content":"SQL Angeles,\nWe had a meeting at 2/14, Los Angeles.\nHere are the presentation file and Demo script.\nTopic : Transaction Management and the Transaction Log\nDownLoad\nSQLPassNew February : sqlpass_news_chapter-deck-february-2017-2\nSQL Angeles is the Local Chapter based on Los Angeles area.\nOur community is for Korean SQL people.\nSo, we do speak in Korean during the presentation.\nThis time is the first try with Skype Business Online.\nWe had 5 people from Local and 9 people joined in Skype Business and shared the session together.\nThank you very much for participated in.\nHere is the detail information how to register and join us.\nhttp://sqlmvp.kr/220936150336\n","date":"2017-02-15T17:47:29-08:00","permalink":"/2017/02/15/sql-angeles-meeting-214-los-angeles/","title":"SQL Angeles Meeting 2/14 - Los Angeles"},{"content":" ALTER DATABASE SET DELAYED_DURABILITY = {option} Disabled –Normal behavior durability guaranteed.(Default) Allowed –Allowed at the DB Level, Transaction has to specify durability options, default is a durable transaction. COMMIT TRAN……. WITH (DELAYED_DURABILITY=ON) FORCED –Changes default durability for the DB to “delayed”. Can be useful for Applications bottlenecked on Log IO, that can tolerate some Data loss on a failure. https://msdn.microsoft.com/en-us/library/dn449490(v=sql.120).aspx\nhttp://info.tricoresolutions.com/blog/delayed-durability-diminishes-i/o-throughput-to-improve-performance-in-the-sql-query\n","date":"2017-02-14T13:20:38-08:00","permalink":"/2017/02/14/delayed-durability/","title":"Delayed Durability"},{"content":"https://sqlperformance.com/2013/08/t-sql-queries/parameter-sniffing-embedding-and-the-recompile-options\n","date":"2017-02-06T11:35:26-08:00","permalink":"/2017/02/06/parameter-sniffing-recompile-options/","title":"parameter sniffing recompile options"},{"content":"SQLCMD mode in SSMS\nHere are some commands very useful. Things help to deploy complicated queries.\n1 2 3 4 5 6 7 8 9 10 11 12 13 :CONNECT localhost :setvar DBA \u0026#34;DBA\u0026#34; :on error exit GO USE [$(DBA)] go SELECT DB_NAME() print \u0026#39;abc.sql -- Simon\u0026#39; :r c:\\temp\\abc.sql GO print \u0026#39;abcdef.sql -- Simon\u0026#39; :r c:\\temp\\abcdef.sql GO ","date":"2017-02-01T10:52:31-08:00","permalink":"/2017/02/01/sqlcmd-mode-in-ssms/","title":"SQLCMD mode in SSMS"},{"content":"enable the Visual studio ssms team explorer : C:\\Program Files (x86)\\Microsoft SQL Server\\130\\Tools\\Binn\\ManagementStudio\\ssms.pkgundef\nhttps://blogs.technet.microsoft.com/dataplatforminsider/2016/11/21/source-control-in-sql-server-management-studio-ssms/\nComments (archived from WordPress) Robert C Ditto · 2017-11-30\nWhat if you don’t have that file in that location? I have it in C:\\Program Files (x86)\\Microsoft SQL Server\\120\\Tools\\Binn\\ManagementStudio but there are no lines pertaining to Team Foundation.\nSimon Cho · 2017-11-30\nWhat is your SSMS version?\n","date":"2017-01-31T17:26:11-08:00","permalink":"/2017/01/31/source-control-in-sql-server-management-studio-ssms/","title":"Source Control in SQL Server Management Studio (SSMS)"},{"content":"https://blogs.msdn.microsoft.com/sqlcat/2015/08/17/sql-2016-columnstore-row-group-merge-policy-and-index-maintenance-improvements/\nhttps://msdn.microsoft.com/en-us/library/dn935008.aspx\n","date":"2017-01-10T11:20:09-08:00","permalink":"/2017/01/10/sql-server-column-store-row-group-investigation/","title":"SQL Server Column store row group investigation"},{"content":"안녕하세요. Simon Cho입니다.\n발표자료 Download : link\nDemo script Download : link\nSQL Angeles 커뮤니티는 SQL PASS의 공식 회원이며, LA Chapter 그룹으로 PASS 커뮤니티중 유일하게 한국어로 진행되는 모임입니다.\nSQL Angeles PASS 공식 홈페이지 : http://SQLAngeles.com / http://sqlangeles.sqlpass.org/\nSQL Angeles 커뮤니티는 정기적으로 화요일 8PM ~ 10PM (2시간) 스터디를 진행하며(장소 및 시간은 공식 홈페이지를 통해 공지 합니다.) SQL Server를 함께 공부하고 다양한 IT 트렌드를 공유하는 기술 및 네트워크를 공유하는 모임 입니다. SQL Angeles 스터디에 참여하고 싶은 분들은 카카오톡(ID : SQLMVP), 페이스북(https://www.facebook.com/sqlmvp) 메신저, email(jevida@naver.com) 등으로 연락 주시기 바랍니다. 스터디 장소의 출입이 자유롭지 못한 관계로 반드시 사전에 협의가 되어야 합니다.\n스터디는 회원제로 운영되며 월회비($20)가 있습니다. 불성실 회원의 경우 회칙에 따라 참여 또는 기타 활동이 제한될 수 있습니다.\n오늘의 주제는 [Build ETL efficiently (10x) with Minimal Logging]으로 제가(Simon Cho) 발표 하였습니다. 오늘 스터디는 총 7분이 참여주셨습니다.\n","date":"2016-12-08T17:31:30-08:00","permalink":"/2016/12/08/sqlangeles-presentation-1262016/","title":"SQLAngeles presentation - 12/6/2016"},{"content":"https://blogs.msdn.microsoft.com/alwaysonpro/2014/06/03/connection-timeouts-in-multi-subnet-availability-group/\nhttp://windowsitpro.com/sql-server-2012/use-sql-server-alwayson-listener\nhttps://msdn.microsoft.com/en-us/library/hh213417.aspx\nUsing a Listener to Connect to a Read-Only Secondary Replica (Read-Only Routing) Read-only routing refers to the ability of SQL Server to route incoming connections to an availability group listener to a secondary replica that is configured to allow read-only workloads. An incoming connection referencing an availability group listener name can automatically be routed to a read-only replica if the following are true:\nAt least one secondary replica is set to read-only access, and each read-only secondary replica and the primary replica are configured to support read-only routing. For more information, see To Configure Availability Replicas for Read-Only Routing, later in this section. The connection string references an availability group listener, and the application intent of the incoming connection is set to read-only (for example, by using the Application Intent=ReadOnly keyword in the ODBC or OLEDB connection strings or connection attributes or properties). For more information, see Read-Only Application Intent and Read-Only Routing, later in this section. ","date":"2016-12-02T11:43:31-08:00","permalink":"/2016/12/02/ag-listener-setting/","title":"AG Listener setting"},{"content":"https://blogs.msdn.microsoft.com/sqlmeditation/2013/01/01/memory-meditation-the-mysterious-sql-server-memory-consumer-with-many-names/\nSQL Server Memory Related Queries\nhttps://technet.microsoft.com/en-us/library/ms175037.aspx\nhttps://msdn.microsoft.com/en-us/library/cc293624.aspx\nhttps://blogs.msdn.microsoft.com/sqlqueryprocessing/2010/02/16/understanding-sql-server-memory-grant/\nWhat is RESOURCE_SEMAPHORE_QUERY_COMPILE?\nTroubleshooting SQL Server Memory\nhttps://blogs.msdn.microsoft.com/psssql/2009/09/11/fun-with-locked-pages-awe-task-manager-and-the-working-set/\n","date":"2016-11-30T13:04:27-08:00","permalink":"/2016/11/30/memory-troubleshooting/","title":"Memory troubleshooting"},{"content":"SQL server 기본 세팅이던 T1117 과 T1118이 SQL 2016에서 변경 되었습니다.\n기본적으로 SQL server 2016 Install 시에 둘다 enable이 되는데요.\n이를 확인하기 위해서는 다음 script를 실행하시면 됩니다.\nIs_Mixed_Page_Allocation_on : 0 = T1118(Enable)\nIs_autogrow_all_files : 1 = T1117(Enable)\n1 2 3 4 5 SELECT name, is_mixed_page_allocation_on FROM sys.databases WHERE name=\u0026#39;Tempdb\u0026#39; SELECT is_autogrow_all_files FROM tempdb.sys.filegroups https://blogs.msdn.microsoft.com/psssql/2016/03/15/sql-2016-it-just-runs-faster-t1117-and-t1118-changes-for-tempdb-and-user-databases/\n","date":"2016-11-28T16:16:35-08:00","permalink":"/2016/11/28/sql-server-2016-t1117-and-t1118/","title":"SQL server 2016 -T1117 and -T1118"},{"content":"First of all we can check SQL server version since there is patch regarding bucket count.\nhttps://support.microsoft.com/en-us/kb/3026082\nhttps://support.microsoft.com/en-us/kb/3026083\nhttps://support.microsoft.com/en-us/kb/3175883\nIdentifying queries with SOS_SCHEDULER_YIELD waits\nAdvanced SQL Server performance tuning\nNew whitepapers on latches and spinlocks published\nhttps://blogs.msdn.microsoft.com/repltalk/2011/02/08/what-does-high-wait-in-sos_scheduler_yield-mean/\nAnd here is really good blog about this issue.\nhttps://exadat.co.uk/2015/03/31/spinlocks-when-to-worry-about-them-and-solutions-to-common-problems/\n","date":"2016-11-18T11:23:02-08:00","permalink":"/2016/11/18/sos_scheduler_yield-due-to-spinlock-issue/","title":"SOS_SCHEDULER_YIELD due to SpinLock issue."},{"content":"안녕하세요. Simon 입니다.\n어제 발표 했던 Index 자료 공유 합니다.\n멀리서도 참여 해 주셔서 많은 힘이 되었네요.\n저희 SQL Angeles 잘 함 진행해 보아요.\n강성욱씨 post : http://sqlmvp.kr/220863249821\nScript and Presentation download link.\n","date":"2016-11-16T18:33:54-08:00","permalink":"/2016/11/16/sqlangeles_20161116/","title":"[LA DB 스터디] 2016-11-15 LA 한인 SQL Angeles 스터디 모임"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 CREATE PROCEDURE [dbo].[P_AddErrorLog] @IsRaiseErrorOn BIT = 1 , @IsRaiseErrorWithLogOn BIT = 0 -- Ignored where @IsRaiseErrorOn = 0 , @IsRollBackTranOn BIT = 1 -- Ignored where XACT_STATE() = -1. It will be Rollback anyway.(Recommanded always turn on \u0026#34;@IsRollBackTranOn=1\u0026#34; since error logging will be rollback as well in parent SP. , @CustomMessage NVARCHAR(4000) = NULL -- Anyother message want to store such as parameter and e.t.c.. WITH EXECUTE AS OWNER AS BEGIN SET NOCOUNT ON; SET XACT_ABORT ON; DECLARE @intReturnValue int; DECLARE @nvcErrorMessage nvarchar(4000), @intErrorNumber int, @intErrorSeverity int, @intErrorState int, @intErrorLine int, @nvcErrorProcedure nvarchar(128); /**_# Log the error.*/ /**_## Assign variables to error-handling functions that capture information for RAISERROR.*/ SET @intErrorNumber = ERROR_NUMBER(); SET @intErrorSeverity = ERROR_SEVERITY(); SET @intErrorState = ERROR_STATE(); SET @intErrorLine = ERROR_LINE(); SET @nvcErrorProcedure = ERROR_PROCEDURE(); SET @nvcErrorMessage = ISNULL(ERROR_MESSAGE(),\u0026#39;NULL\u0026#39;); /**_# If there is no error information to log, return 0.*/ IF @intErrorNumber IS NULL BEGIN SET @intReturnValue = 0; GOTO Done; END ELSE BEGIN SET @intReturnValue = @intErrorNumber; END /**_# Rollback and return if inside an uncommittable transaction.*/ IF XACT_STATE() = -1 BEGIN BEGIN TRAN --Trick to remove this error: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0. ROLLBACK TRANSACTION; SET @nvcErrorMessage = \u0026#39;[System : uncommittable transaction] \u0026#39;+ @nvcErrorMessage; END /**_# Rollback and return if @IsRollBackTranOn and Trancount\u0026gt;0.*/ IF @IsRollBackTranOn = 1 AND @@TRANCOUNT \u0026gt; 0 BEGIN BEGIN TRAN --Trick to remove this error: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0. ROLLBACK TRANSACTION; END /**_## Log the error that occurred.*/ INSERT dbo.ErrorLogs (LoginName, HostName, ErrorNumber, ErrorSeverity, ErrorState, ErrorProcedure, ErrorLine, ErrorMessage, CustomMessage, Registered_DateTime) VALUES (CAST(ORIGINAL_LOGIN() AS nvarchar(128)), CAST(HOST_NAME() AS nvarchar(128)), @intErrorNumber, @intErrorSeverity, @intErrorState, @nvcErrorProcedure, @intErrorLine, @nvcErrorMessage, @CustomMessage, GETDATE()); /**_# Rethrow the error.*/ IF @IsRaiseErrorOn = 1 BEGIN SET @nvcErrorMessage = N\u0026#39;Error %d, Level %d, State %d, Procedure %s, Line %d, Message: \u0026#39; + @nvcErrorMessage; IF @IsRaiseErrorWithLogOn = 1 BEGIN RAISERROR (@nvcErrorMessage, @intErrorSeverity, 1, @intErrorNumber, @intErrorSeverity, @intErrorState, @nvcErrorProcedure, @intErrorLine) WITH LOG; END ELSE BEGIN RAISERROR (@nvcErrorMessage, @intErrorSeverity, 1, @intErrorNumber, @intErrorSeverity, @intErrorState, @nvcErrorProcedure, @intErrorLine); END END Done: RETURN @intReturnValue; END ","date":"2016-11-07T16:20:23-08:00","permalink":"/2016/11/07/global-errorlog-sp-example/","title":"Global ErrorLog SP example"},{"content":"Topic : Build ETL efficiently (10x) with Minimal Logging\nPresentation File Download Link\n","date":"2016-09-24T22:12:50-07:00","permalink":"/2016/09/24/sql-saturday-session-563-dallas-9242016/","title":"SQL Saturday Session #563 - Dallas 9/24/2016"},{"content":"We need to check a couple of setting.\nService broker Enable : By default disabled even restored from Primary Doesn’t allow enabled broker in AG setting. It’s required remove first. First failover only. Trustworthy On : By default off even restored from Primary. First failover only. Encryption/Decryption issue Database master key encrypted by “Service Master key”. So secondary instance can’t encrypt/decrypt master key since Service master key created at the first installation. Temporary solution : alter master key with current instance service master key Once failover, it need to execute. #Service Master key\nScript\n1 2 3 4 5 6 7 8 9 10 11 12 13 -- #1 : First failover only. Remove AG required. After run the script we can rejoin it. SELECT name FROM sys.databases WHERE is_broker_enabled=1 -- If you don\u0026#39;t see your DB. need to run below command. ALTER DATABASE \u0026lt;ServiceBrokerDB\u0026gt; SET ENABLE_BROKER GO -- #2 : Concorrunt connection may be interuppted. First failover only. SELECT name FROM sys.databases WHERE is_trustworthy_on=1 -- If you don\u0026#39;t see your DB. need to run below command. ALTER DATABASE \u0026lt;ServiceBrokerDB\u0026gt; SET TRUSTWORTHY ON GO -- #3 : Need to execute it every failover. More detail please see \u0026#34;Service Master Key\u0026#34; document. OPEN MASTER KEY DECRYPTION BY PASSWORD = \u0026#39;x\u0026#39; -- Should be encrypted! See below ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY ","date":"2016-09-22T16:09:57-07:00","permalink":"/2016/09/22/service-broker-may-not-work-after-failover-in-ag/","title":"Service Broker may not work after Failover in AG."},{"content":"https://blogs.msdn.microsoft.com/mattm/2012/09/19/ssis-with-alwayson/\nhttp://help.k2.com/kb001572\nhttps://technet.microsoft.com/en-us/library/ms182754%28v=sql.110%29.aspx\nTemporary solution : Alter master key again with service master key\nOPEN MASTER KEY DECRYPTION BY PASSWORD = ‘x’ — Should be encrypted! See below ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY\nHere is SQL server 2016 AG setting.\nIt seems like working with SQL 2014 as well.\nhttps://blogs.msdn.microsoft.com/alwaysonpro/2016/06/23/sql-server-2016-alwayson-availability-group-enhancements-support-for-encrypted-databases/\n","date":"2016-09-22T15:59:07-07:00","permalink":"/2016/09/22/service-master-key-issue-on-ag/","title":"Service Master Key issue on AG"},{"content":"Build ETL efficiently (10x) with Minimal Logging\nHere is the Presentation file. Link\nhttp://saturdaynightsql.sqlpass.org/Home.aspx?EventID=5824\nI wish to have 2-3 hour presentation length.\n1 hour is short to share all those information.\n","date":"2016-09-12T14:48:46-07:00","permalink":"/2016/09/12/saturday-night-sql-vc-910-ml-etl/","title":"Saturday Night SQL VC 9/10 - Build ETL efficiently (10x) with Minimal Logging"},{"content":"I spoke at Oklahoma City 8/27/2016. This is first visit at Oklahoma City.\nIt was an awesome experience.\nYou can download my presentation at here.\nhttp://www.sqlsaturday.com/553/Sessions/Schedule.aspx\n","date":"2016-08-27T14:21:25-07:00","permalink":"/2016/08/27/sql-saturday-oklahoma-city/","title":"SQL Saturday - oklahoma city"},{"content":"https://technet.microsoft.com/en-us/library/ms190692.aspx\nCompared to the full recovery model, which fully logs all transactions, the bulk-logged recovery model minimally logs bulk operations, although fully logging other transactions. The bulk-logged recovery model protects against media failure and, for bulk operations, provides the best performance and least log space usage.\nHowever, the bulk-logged recovery model increases the risk of data loss for these bulk-copy operations, because bulk logging operations prevents recapturing changes on a transaction-by-transaction basis. If a log backup contains any bulk-logged operations, you cannot restore to a point-in-time within that log backup; you can restore only the whole log backup.\nSolution : We can run Log backup more frequently during a minimal logging operation.\nhttps://technet.microsoft.com/en-us/library/ms190203(v=sql.105).aspx\nFor a database that uses full recovery, switching to the bulk-logged recovery model temporarily for bulk operations improves performance. However, point-in-time recovery is not possible with bulk-logged model. Therefore, if you run transactions under the bulk-logged recovery model that might require a transaction log restore, these transactions could be exposed to data loss. To maximize data recoverability in a disaster-recovery scenario, we recommend that you switch to the bulk-logged recovery model only under the following conditions:\nUsers are currently not allowed in the database. All modifications made during bulk processing are recoverable without depending on taking a log backup; for example, by re-running the bulk processes. If you satisfy these two conditions, you will not be exposed to any data loss while restoring a transaction log that was backed up under the bulk-logged recovery model.\nWe recommend that:\nBefore switching to the bulk-logged recovery model, you back up the log.This is important because, under the bulk-logged recovery model, if the database fails, backing up the log for bulk operations requires access to the data. After performing the bulk operations, you immediately switch back to full recovery mode. After switching back from the bulk-logged recovery model to the full recovery model, you back up the log again. ","date":"2016-08-01T12:36:43-07:00","permalink":"/2016/08/01/bulk-recovery-model/","title":"Bulk recovery model - Concerning about Point-in-time recovery."},{"content":"http://www.sqlsaturday.com/540/EventHome.aspx\nIt was the first session in the moring.\nThank you for joining.\nPresentation File\n","date":"2016-07-23T10:14:35-07:00","permalink":"/2016/07/23/7232016-sql-saturday-at-sacramento/","title":"7/23/2016 SQL Saturday at Sacramento"},{"content":"Thank you all.\nHere are the presentation file and script.\nhttp://sql.la/\n","date":"2016-07-22T12:17:42-07:00","permalink":"/2016/07/22/sql-la-presentation-file-721/","title":"SQL.LA presentation file 7/21."},{"content":"I create one SP to execute SSIS Catalog using T-SQL.\nIt sometimes helps to execute SSIS package dynamically.\nFull script download link.\nexec [dbo].[USP_EXEC_SSIS_Catalog] @folder_name NVARCHAR(128) , @project_name NVARCHAR(128) , @package_name NVARCHAR(260) , @Multi_CustomValue VARCHAR(MAX)= NULL –“|#||##||#|… Ex. “SyncBack_Period_DD|#|-14|##|BackupFolder|#|X:\\Test” , @reference_id BIGINT = NULL , @use32bitruntime BIT = 0 , @execution_id BIGINT = NULL OUTPUT\n","date":"2016-06-10T13:17:04-07:00","permalink":"/2016/06/10/ssis-catalog-execution-with-t-sql/","title":"SSIS Catalog Execution with T-SQL"},{"content":"Please register it on SQL Saturday page\nhttp://www.sqlsaturday.com/524/eventhome.aspx\nBuild ETL efficiently (10x) with Minimal Logging : Presentation Myths and Truths about SQL Server Transaction : Presentation, Demo @sqlsatSoFla #sqlsat524 #sqlsaturday\n","date":"2016-06-10T11:02:11-07:00","permalink":"/2016/06/10/im-going-to-speak-at-south-florida/","title":"I’m going to Speak at South Florida, 6/18 - Update Download link"},{"content":"SQL Server 2016 is released at 6/1.\nhttps://www.microsoft.com/en-us/server-cloud/products/sql-server/\nSQL Server 2014/2016 Developer edition are free after joining Visual Studio Dev Essentials.\nhttps://www.microsoft.com/en-us/server-cloud/products/sql-server/\nBefore install Please read release note. They ask VC runtime update before installation.\nhttps://msdn.microsoft.com/en-us/library/dn876712.aspx\nInstall Patch Requirement (GA) Issue and customer impact: Microsoft has identified a problem that affects the Microsoft VC++ 2013 Runtime binaries that are installed as a prerequisite by SQL Server 2016. An update is available to fix this problem. If this update to the VC runtime binaries is not installed, SQL Server 2016 may experience stability issues in certain scenarios. Before you install SQL Server 2016, check to see if the server needs the patch described in KB 3138367 – Update for Visual C++ 2013 and Visual C++ Redistributable Package.\nKB 3138367 is required if the build version of msvcr120.dll is not 12.0.40649.5 or higher. To check the file build version:\nOpen Windows Explorer. Navigate to %SystemRoot%\\system32\\msvcr120.dll. Right-click the file and then click Properties. Click the Details tab. Verify the file version is 12.0.40649.5 or higher. If the build version of msvcr120.dll is not 12.0.40649.5 or higher you need to install KB 3138367.\nResolution: To install this required update, download and run the appropriate vcredist_*.exe based on your system language and architecture from KB 3138367.\nIf you have SQL Server 2016 installed on a computer that needs KB 3138367, do the following steps in order:\nDownload the appropriate vcredist_*exe. Stop the SQL Server service for all instances of the database engine. Install KB 3138367. Reboot the computer. ","date":"2016-06-03T10:40:06-07:00","permalink":"/2016/06/03/sql-server-2016-is-released-developer-edition-is-free/","title":"SQL Server 2016 installation"},{"content":"http://saturdaynightsql.sqlpass.org/\nPresentation file download link.\nScript file download link.\nThis is all about SQL error handling and nested transaction issue.\nI’ll do a presentation for “Myths and Truths about SQL Server Transaction” at Saturday Night SQL, 5/7 6:00 PM PST.\nThis is Virtual Chapter. So, you can join on online.\n","date":"2016-05-02T10:37:45-07:00","permalink":"/2016/05/02/myths-and-truths-about-sql-server-transaction-at-saturday-night-sql-57-600-pm-pst/","title":"“Myths and Truths about SQL Server Transaction” at Saturday Night SQL, 5/7 6:00 PM PST."},{"content":"https://support.microsoft.com/en-us/kb/2964518\nMust read who is using SQL Server 2012 or SQL Server 2014.\n","date":"2016-04-04T11:09:28-07:00","permalink":"/2016/04/04/recommended-updates-and-configuration-options-for-sql-server-2012-and-sql-server-2014-with-high-performance-workloads/","title":"Recommended updates and configuration options for SQL Server 2012 and SQL Server 2014 with high-performance workloads"},{"content":"Presentation file is here. 20160409_BestPracticeForETL-MinimalLogging\nhttp://www.sqlsaturday.com/493/Sessions/Schedule.aspx\nI’m going to Silicon Valley to Speak on SQL Saturday.\nTopic: “Best Practice for ETL – How to use minimal logging, and when? “\nLocation : Microsoft Technology Center, 1065 La Avenida, Mountain View, California, 94043, United States\n","date":"2016-03-30T15:37:43-07:00","permalink":"/2016/03/30/49-silicon-valley-to-speak-on-sql-saturday/","title":"4/9 Silicon Valley to speak on SQL Saturday."},{"content":"CHECKDB From Every Angle: Complete description of all CHECKDB stages\nCorruption bug that people are hitting: Msg 8914 – PFS free space\nThanks, Paul\n","date":"2016-01-25T18:04:00-08:00","permalink":"/2016/01/25/checkdb-detail/","title":"checkDB detail"},{"content":"First of all, let’s take a look system view\nsp_helptext ‘sys.sysfiles’ sp_helptext ‘master.dbo.sysaltfiles’\n\u0026lt;Sys.sysfiles – SQL2014\u0026gt;\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 CREATE VIEW sys.sysfiles AS SELECT fileid = convert(smallint, fileid \u0026amp; 0x7fff), groupid = convert(smallint, grpid), size = isnull(FilePropertyById(fileid, \u0026#39;size\u0026#39;), size), maxsize, growth, status = convert(int, case filetype when 1 then 66 else 2 end -- x_eft_SQLLog, FCB_LOG_DEVICE, FCB_DSK_DEVICE + (status \u0026amp; 8) * 2 -- FCB_READONLY_MEDIA + (status \u0026amp; 16) * 256 -- FCB_READONLY + case filestate when 6 then 268435456 else 0 end -- OFFLINE, FCB_OFFLINE + (status \u0026amp; 256) * 2097152 -- FCB_SPARSE_FILE + (status \u0026amp; 32) * 32768), -- FCB_PERCENT_GROWTH perf = convert(int, 0), name = lname, filename = pname FROM sys.sysprufiles WHERE filetype IN (0, 1) -- x_eft_SQLData, x_eft_SQLLog (bwkcmpt types) AND filestate NOT IN (1, 2, 3) -- x_efs_Dummy, x_efs_Dropped, x_efs_DroppedReusePending \u0026lt;master.dbo.sysaltfiles – SQL2014\u0026gt;\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 CREATE VIEW sys.sysaltfiles AS SELECT fileid = convert(smallint, f.fileid \u0026amp; 0x7fff), groupid = convert(smallint, f.grpid), f.size, f.maxsize, f.growth, status = convert(int, case f.filetype when 1 then 66 else 2 end -- x_eft_SQLLog, FCB_LOG_DEVICE, FCB_DSK_DEVICE + (f.status \u0026amp; 8) * 2 -- FCB_READONLY_MEDIA + (f. status \u0026amp; 16) * 256 -- FCB_READONLY + case when f.filestate in (1, 2, 3, 6) then 268435456 else 0 end -- OFFLINE, FCB_OFFLINE + (f.status \u0026amp; 256) * 2097152 -- FCB_SPARSE_FILE + (f.status \u0026amp; 32) * 32768), -- FCB_PERCENT_GROWTH perf = convert(int, 0), dbid = convert(smallint, f.dbid), name = f.lname, filename = f.pname FROM master.sys.sysbrickfiles f WHERE f.filetype IN (0, 1) AND has_access(\u0026#39;MF\u0026#39;, 1) = 1 -- x_eft_SQLData, x_eft_SQLLog (bwkcmpt types) You can find out the source code looks like below for status\nstatus = convert(int, case filetype when 1 then 66 else 2 end — x_eft_SQLLog, FCB_LOG_DEVICE, FCB_DSK_DEVICE\n(status \u0026amp; 8) * 2 — FCB_READONLY_MEDIA (status \u0026amp; 16) * 256 — FCB_READONLY case filestate when 6 then 268435456 else 0 end — OFFLINE, FCB_OFFLINE (status \u0026amp; 256) * 2097152 — FCB_SPARSE_FILE (status \u0026amp; 32) * 32768), — FCB_PERCENT_GROWTH This is bit operation. So, it need to convert back using same operation.\nSELECT * , status , status \u0026amp; 2 AS [FCB_DSK_DEVICE] , status \u0026amp; 66 AS [FCB_LOG_DEVICE] , status \u0026amp; (8 * 2) AS [FCB_READONLY_MEDIA] , status \u0026amp; (16 * 256) AS [FCB_READONLY] , status \u0026amp; (268435456) AS [OFFLINE, FCB_OFFLINE] , status \u0026amp; (256 * 2097152) AS [FCB_SPARSE_FILE] , status \u0026amp; (32 * 32768) AS [FCB_PERCENT_GROWTH] FROM master..sysaltfiles\nThis query equivalent with below query\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 /* SELECT CONVERT(VARBINARY(8), 2) SELECT CONVERT(VARBINARY(8), 66) SELECT CONVERT(VARBINARY(8), (8 * 2)) SELECT CONVERT(VARBINARY(8), (16 * 256)) SELECT CONVERT(VARBINARY(8), 268435456) SELECT CONVERT(VARBINARY(8), (256 * 2097152)) SELECT CONVERT(VARBINARY(8), (32 * 32768)) */ SELECT * , status , status \u0026amp; 0x2 AS [FCB_DSK_DEVICE] , status \u0026amp; 0x42 AS [FCB_LOG_DEVICE] , status \u0026amp; 0x10 AS [FCB_READONLY_MEDIA] , status \u0026amp; 0x1000 AS [FCB_READONLY] , status \u0026amp; 0x10000000 AS [OFFLINE, FCB_OFFLINE] , status \u0026amp; 0x20000000 AS [FCB_SPARSE_FILE] , status \u0026amp; 0x100000 AS [FCB_PERCENT_GROWTH] FROM master..sysaltfiles BOL saying “0x40 = Log file.” since this is bit operation.\nI realized it. It’s due to “FCB_DSK_DEVICE” included. So, 0x40+2 = 0x42.\nSo, 0x40 is for FCB_LOG_DEVICE\nhttps://msdn.microsoft.com/en-us/library/ms178009.aspx\nFinal query\nSELECT * , status , CONVERT(BIT, status \u0026amp; 0x2) AS [FCB_DSK_DEVICE] , CONVERT(BIT, status \u0026amp; 0x40) AS [FCB_LOG_DEVICE] , CONVERT(BIT, status \u0026amp; 0x10) AS [FCB_READONLY_MEDIA] , CONVERT(BIT, status \u0026amp; 0x1000) AS [FCB_READONLY] , CONVERT(BIT, status \u0026amp; 0x10000000) AS [OFFLINE, FCB_OFFLINE] , CONVERT(BIT, status \u0026amp; 0x20000000) AS [FCB_SPARSE_FILE] , CONVERT(BIT, status \u0026amp; 0x100000) AS [FCB_PERCENT_GROWTH] FROM master..sysaltfiles\nComments (archived from WordPress) **** · 2020-07-03\nBeautiful stuff. We dbas are way out of touch with the underlying file system.\n","date":"2016-01-04T18:13:56-08:00","permalink":"/2016/01/04/understading-status-column-of-sysfiles-and-sysaltfiles-view/","title":"understading status column of sysfiles and sysaltfiles view"},{"content":"There are 2 issues in case of primary server has 512 sector size, and secondary server has 4096 sector size\nYou may see below message in the SQL server error log There have been 170613760 misaligned log IOs which required falling back to synchronous IO. The current IO is on file\nIf you are using Log Shipping with standby mode on secondary server, standby mode may fail frequently. 1 2 Msg 9004, Level 16, State 6, Line 7 An error occurred while processing the log for database \u0026#39;MessageExchange_Sanpedro\u0026#39;. If possible, restore from backup. If a backup is not available, it might be necessary to rebuild the log. Please check 4k and 512 basic concept in below url.\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2014/10/02/message-misaligned-log-ios-which-required-falling-back-to-synchronous-io-in-sql-server-error-log.aspx\nhttp://blogs.msdn.com/b/psssql/archive/2011/01/13/sql-server-new-drives-use-4k-sector-size.aspx\nhttp://blogs.msdn.com/b/psssql/archive/2013/05/15/sql-server-storage-spaces-vhdx-and-4k-sector-size.aspx\nSolution\nhttps://support.microsoft.com/en-us/kb/3009974 : I don’t know how it work internally. It might force the primary to 4K alignment. Please fully test it out and apply it.\nNote After you apply this hotfix, you have to turn on the trace flag 1800 to make this hotfix work correctly.\nhttps://support.microsoft.com/en-us/kb/2987585 : This one is great. Need to turn on trace flag 3057\nThanks Bob ward and Robert Dorr for investigation.\nComments (archived from WordPress) Kevin Ojunta · 2019-01-28\nwe are on sql 2017 and even after applying T1800, misaligned I/O messages still show up on the error log. performance did improve however. is this common?\nSimon Cho · 2019-03-07\nI just checked your message. Could you provide more detail? What is the exact version of your SQL. Could you send @@Version result?\nDid you enable it on Secondary or Primary?\n","date":"2015-11-16T18:12:05-08:00","permalink":"/2015/11/16/between-4096-and-512-sector-size-issue/","title":"Between 4096 and 512 sector size issue."},{"content":"download link\n","date":"2015-08-20T14:10:27-07:00","permalink":"/2015/08/20/speak-at-huntington-beach-4112015/","title":"Speak at Huntington Beach 4/11/2015"},{"content":"SQL server 2012 or 2014.\nPlease check service pack first. SQL server 2012 https://support.microsoft.com/en-us/kb/2837964\nSQL server 2014 https://support.microsoft.com/en-us/kb/2993859\nIf you have still problem, please check that memory pressure. You may can find warning on event log. Unexpected_Termination\nUnexpected_termination_EventLog\n","date":"2015-07-08T17:24:33-07:00","permalink":"/2015/07/08/ssis-package-unexpected-termination/","title":"SSIS package unexpected Termination"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 SELECT replica_server_name , d.role_desc , d.connected_state_desc --, endpoint_url --, availability_mode_desc --, failover_mode_desc --, session_timeout --, backup_priority --, secondary_role_allow_connections_desc AS Secondary_Readable , Pri_Check.pri_Status --, Pri_Check.Sec_Status --, Pri_Check.Sync_Status , d.operational_state_desc , d.recovery_health_desc , d.synchronization_health_desc AS Sync_Status , d.last_connect_error_description AS ErrorMsg , DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), GETDATE()), d.last_connect_error_timestamp) AS ErrorDateTime FROM sys.availability_replicas r OUTER APPLY ( SELECT 1 AS IsPrimary , c.ip_address AS listnerIP , c.state_desc AS listnerStatus , a.primary_recovery_health_desc AS pri_Status , a.secondary_recovery_health_desc AS Sec_Status , a.synchronization_health_desc AS Sync_Status FROM sys.dm_hadr_availability_group_states a JOIN sys.availability_group_listeners B ON A.group_id = B.group_id JOIN sys.availability_group_listener_ip_addresses c ON b.listener_id = c.listener_id WHERE primary_replica = r.replica_server_name ) Pri_Check JOIN sys.dm_hadr_availability_replica_states d ON r.replica_id = d.replica_id /* WHERE d.role NOT IN (1,2) -- 1:Primary, 2:Secondary, 0:Resolving OR d.operational_state \u0026lt;\u0026gt; 2 --0 = Pending failover, 1 = Pending, 2 = Online, 3 = Offline, 4 = Failed, 5 = Failed, no quorum OR d.recovery_health \u0026lt;\u0026gt; 1 --0:In progress. At least one joined database has a database state other than ONLINE ( database_state is not 0).1- Online. All the joined databases have a database state of ONLINE ( database_state is 0). OR d.synchronization_health \u0026lt;\u0026gt;2 -- 0 = Not healthy. At least one joined database is in the NOT SYNCHRONIZING state. -- 1 = Partially healthy. Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing. -- 2= Healthy. All replicas are in the target synchronization state: synchronous-commit replicas are synchronized, and asynchronous-commit replicas are synchronizing. OR d.connected_state \u0026lt;\u0026gt; 1 --0 Disconnected. The response of an availability replica to the DISCONNECTED state depends on its role, as follows: -- On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as NOT SYNCHRONIZED on the primary replica, which waits for the secondary to reconnect. -- On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica. -- 1 Connected OR d.last_connect_error_number IS NOT NULL */ ","date":"2015-06-15T14:42:19-07:00","permalink":"/2015/06/15/alwayson-ag-group-status-check/","title":"AlwaysOn AG group status check"},{"content":"https://support.microsoft.com/en-us/kb/2936603\nSQL service pack SP1 is announced.\nhttps://support.microsoft.com/en-us/kb/2936603\nAnd CU7 and SP1 both of the latest build for now.\nThe problem is, SP1 has higher version. But, it looks not containing CU6 and CU7.\nCU6 and CU7 include very critical KB as well.\nYou may not want to apply SP1. Please check CU6 and CU7 first.\nServicePack VSTS bug number KB article number Description Fix area CU6 4067265 3016165 FIX: Arithmetic overflow error occurs when you add manually initialized subscriptions for publication in SQL Server SQL service CU6 4067300 3021757 FIX: Duplicate sequence value is generated when you run sp_sequence_get_range in parallel with NEXT VALUE FOR function SQL service CU6 3986465 3024815 Large query compilation waits on RESOURCE_SEMAPHORE_QUERY_COMPILE in SQL Server 2014 SQL performance CU6 3915402 3025845 FIX: The transaction isolation level is reset incorrectly when the SQL Server connection is released in SQL Server 2014 SQL service CU6 4067260 3026082 FIX: SOS_CACHESTORE spinlock contention on system table rowset cache causes high CPU usage in SQL Server 2012 or 2014 SQL service CU6 4067263 3026083 FIX: SOS_CACHESTORE spinlock contention on ad hoc SQL Server plan cache causes high CPU usage in SQL Server 2012 or 2014 SQL service CU6 3856439 3029762 FIX: Access violation occurs when you delete rows from a table that has clustered columnstore index in SQL Server 2014 SQL service CU6 4067312 3029825 FIX: DBCC CHECKDB and DBCC CHECKTABLE take longer to run when SQL CLR UDTs are involved in SQL Server 2012 or SQL Server 2014 SQL performance CU6 3885366 3030041 FIX: Error occurs when you connect to the database engine after you install CU4 for SQL Server 2014 Setup \u0026amp; Install CU6 3749961 3030619 FIX: Incorrect data returned when you use DATE data type as a qualifier in a query in SQL Server 2014 SQL service CU6 4072235 3034615 FIX: Memory leak occurs when you run DBCC CHECKDB against a database in SQL Server 2014 SQL service CU6 4045776 3034679 FIX: AlwaysOn availability groups are reported as NOT SYNCHRONIZING High Availability CU7 4210782 3042544 FIX: A query that requires nested loops join takes longer to complete in SQL Server 2014 SQL performance CU7 4326599 3044958 FIX: Rollback recovery on a snapshot fails when you run DBCC CHECKDB and then SQL Server shuts down unexpectedly SQL service CU7 4326597 3032476 FIX: Memory leak in USERSTORE_SCHEMAMGR and CPU spikes occur when you use temp table in SQL Server 2012 or 2014 SQL service CU7 4336264 3037624 FIX: Complex parallel query does not respond in SQL Server 2012 or SQL Server 2014 SQL performance CU7 4265652 3042370 An AlwaysOn secondary replica crashes or raises error 3961 when the AlwaysOn database has CLR UDT in SQL Server 2014 SQL service CU7 4326600 3042135 FIX: Access violation and “No exceptions should be raised by this code” error occur when you use SQL Server 2012 or SQL Server 2014 SQL service CU7 4056944 3048752 FIX: A SELECT query run as a parallel batch-mode scan may cause a deadlock situation in SQL Server 2014 SQL service CU7 4302739 3052404 FIX: You cannot use the Transport Layer Security protocol version 1.2 to connect to a server that is running SQL Server 2014 SQL connectivity CU7 4329649 3048856 FIX: Error 3624 occurs when you execute a query that contains multiple bulk insert statements in SQL Server 2014 SQL service CU6 4067280 3011465 FIX: Sequence object generates duplicate sequence values when SQL Server 2012 or SQL Server 2014 is under memory pressure SQL service ","date":"2015-06-15T13:10:15-07:00","permalink":"/2015/06/15/sql-service-pack-for-sql-2014/","title":"SQL 2014 service pack for SP1 or CU7?"},{"content":"http://blogs.msdn.com/b/craigfr/\n","date":"2015-02-24T13:59:25-08:00","permalink":"/2015/02/24/parallelism/","title":"Parallelism"},{"content":"https://kb.netapp.com/support/index?page=content\u0026id=1010881 https://kb.netapp.com/support/index?page=content\u0026id=3011193 https://kb.netapp.com/support/index?page=content\u0026id=1014111 http://www.netapp.com/us/system/pdf-reader.aspx?m=tr-3428.pdf\u0026cc=us http://www.netapp.com/us/system/pdf-reader.aspx?m=tr-3747.pdf\u0026cc=us http://kb.vmware.com/selfservice/microsites/search.do?language=en_US\u0026cmd=displayKC\u0026externalId=1009658\nPartition Alignment and block size VMware 5\nhttps://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf?src=vmdk\nDetermining the file at a specific VMDK offset\nhttp://blogs.msdn.com/b/saponsqlserver/archive/2014/10/02/message-misaligned-log-ios-which-required-falling-back-to-synchronous-io-in-sql-server-error-log.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/hh182553(v=vs.85).aspx http://support.microsoft.com/kb/982018?wa=wsignin1.0 https://msdn.microsoft.com/en-us/library/windows/desktop/hh182553(v=vs.85).aspx http://blogs.msdn.com/b/psssql/archive/2013/05/15/sql-server-storage-spaces-vhdx-and-4k-sector-size.aspx https://technet.microsoft.com/en-us/sqlserver/aa365683(v=vs.100).aspx http://blogs.msdn.com/b/psssql/archive/2011/01/13/sql-server-new-drives-use-4k-sector-size.aspx https://msdn.microsoft.com/en-us/library/windows/desktop/hh848035(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/cc966412.aspx#EEAA http://sqlcommunity.com/SQL-TEAMS/SAP-on-SQL https://kb.netapp.com/support/index?page=content\u0026id=1010803\u0026actp=search\u0026viewlocale=en_US\u0026searchid=1423875704148\nComments (archived from WordPress) pipe dream · 2015-05-19\nIf you are going for best contents like myself, only pay a visit this site all the time as it gives feature contents, thanks\n","date":"2015-02-13T18:03:41-08:00","permalink":"/2015/02/13/misaligned-log-ios-which-required-falling-back-to-synchronous-io/","title":"misaligned log ios which required falling back to synchronous io between 4096 and 512e"},{"content":"Please download file from below link.\nlink\n","date":"2015-01-17T16:58:39-08:00","permalink":"/2015/01/17/sql-saturday-presentation-file-9202014/","title":"SQL Saturday Presentation file - 9/20/2014"},{"content":"Please download from below link to get presentation and Demo file.\nLink ","date":"2015-01-17T16:54:49-08:00","permalink":"/2015/01/17/sql-la-presentation-file-transaction-1152015/","title":"SQL.la Presentation file - Transaction 1/15/2015"},{"content":"This is first presentation in public.\nI choose SQL Saturday in San Diego.\nHere is Presentation file. Transaction\nYou can download it from this url as well.\nhttp://www.sqlsaturday.com/viewsession.aspx?sat=340\u0026sessionid=25091\nPlease download it. And test and use it as own your risk 🙂\nOver all, it’s ok on production environment as well. But, Speaker do not grantee it on your system.\nAs I explained in there is no Generic best practice Stored Procedure template.\nIt need to change based on your business logic.\n","date":"2014-09-22T13:36:10-07:00","permalink":"/2014/09/22/sql-saturday-presentationtransaction-san-diego-920/","title":"SQL Saturday - Presentation(Transaction) - San Diego 9/20"},{"content":"http://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/MDC-B302\n","date":"2014-08-08T11:45:44-07:00","permalink":"/2014/08/08/introduce-desired-state-configuration-in-windows-server-2012/","title":"Introduce Desired State Configuration in Windows Server 2012"},{"content":"http://stackoverflow.com/tags/powershell/info\nCommon Gotchas\nExecuting EXEs via a path with spaces requires quoting the path and the use of the call operator – \u0026amp;\n1 C:\\PS\u0026gt; \u0026amp; \u0026#39;C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe\u0026#39; Calling PowerShell functions does not require parenthesis or comma separated arguments. PowerShell functions should be called just like a cmdlet. The following examples demonstrates the problem caused by this issue e.g.:\n1 2 3 C:\\PS\u0026gt; function Greet($fname, $lname) {\u0026#34;My name is \u0026#39;$lname\u0026#39;, \u0026#39;$fname\u0026#39; \u0026#39;$lname\u0026#39;\u0026#34;} C:\\PS\u0026gt; Greet(\u0026#39;James\u0026#39;,\u0026#39;Bond\u0026#39;) # Wrong way to invoke this function!! My name is \u0026#39;\u0026#39;, \u0026#39;James Bond\u0026#39; \u0026#39;\u0026#39; Note that both ‘James’ and ‘Bond’ are packaged up as a single argument (an array) that is passed to the first parameter. The correct invocation is:\n1 2 C:\\PS\u0026gt; Greet James Bond My name is \u0026#39;Bond\u0026#39;, \u0026#39;James\u0026#39; \u0026#39;Bond\u0026#39; Note that in PowerShell 2.0, the use of Set-StrictMode -version 2.0 will catch this type of problem.\n","date":"2014-08-08T11:02:22-07:00","permalink":"/2014/08/08/basic-powershell-function-call/","title":"Basic powershell function call"},{"content":"SQL 2005\n1 2 3 DBCC HELP(\u0026#39;?\u0026#39;) DBCC TraceOn(2580) DBCC HELP(\u0026#39;?\u0026#39;) SQL 2008 and above\n1 2 3 DBCC HELP(\u0026#39;?\u0026#39;) DBCC TraceOn(2588) DBCC HELP(\u0026#39;?\u0026#39;) ","date":"2014-07-22T14:51:59-07:00","permalink":"/2014/07/22/dbcc-help-want-to-see-all-hidden-dbcc-command/","title":"DBCC help(‘?’) want to see all hidden DBCC command"},{"content":"Log file Shrink has several dependency.\nLog backup(or Checkpoint in simple recovery mode)\nReplication\nMirroring\n4. VLF\n#1,2,3 can be check by this script\n1 2 3 Declare @DBName varchar(255) = \u0026#39;test\u0026#39; select log_reuse_wait_desc from sys.databases where name= @DBName So, most case, it’s ok. But, only #4 can’t be checked by above script.\nPlease use this file to be able to check “StartOffset” for second VLF since LDF required minimum 2 VLFs.\nDBCC LOGINFO\nIf it’s too big, need to refresh VLF.\nBut, unfortunately, refresh VLF isn’t simple.\nTransaction Log VLFs – too many or too few?\nhttp://technet.microsoft.com/en-us/library/aa933049%28v=sql.80%29.aspx\nHigh Virtual Log File (VLF) Count\nThe effect of VLF size on shrinking the log.\nRef. Log_reuse_wait (http://msdn.microsoft.com/en-us/library/ms178534.aspx) 0 = Nothing 1 = Checkpoint 2 = Log backup 3 = Active backup or restore 4 = Active transaction 5 = Database mirroring 6 = Replication 7 = Database snapshot creation 8 = Log Scan 9 = An AlwaysOn Availability Groups secondary replica is applying transaction log records of this database to a corresponding secondary database. 10 = For internal use only 11 = For internal use only 12 = For internal use only 13 = Oldest page 14 = Other (transient)\n","date":"2014-07-15T15:49:18-07:00","permalink":"/2014/07/15/dbcc-shrinkfile-isnt-working-even-simple-recovery-mode/","title":"DBCC SHRINKFILE isn’t working even simple recovery mode."},{"content":"http://www.informit.com/guides/content.aspx?g=sqlserver\u0026seqNum=315\nhttp://msdn.microsoft.com/en-us/library/ms180992(v=sql.120).aspx\nAutomated Administration Across an Enterprise Automating administration across multiple instances of SQL Server is called multiserver administration. Use multiserver administration to do the following:\nManage two or more servers. Schedule information flows between enterprise servers for data warehousing. To take advantage of multiserver administration, you must have at least one master server and at least one target server. A master server distributes jobs to, and receives events from, target servers. A master server also stores the central copy of job definitions for jobs that are run on target servers. Target servers connect periodically to the master server to update their schedule of jobs. If a new job exists on the master server, the target server downloads the job. After the target server completes the job, it reconnects to the master server and reports the status of the job.\nThe following illustration shows the relationship between master and target servers:\nIf you administer departmental servers across a large corporation, you can define the following:\nOne backup job with job steps. Operators to notify in case of backup failure. An execution schedule for the backup job. ","date":"2014-07-03T15:31:57-07:00","permalink":"/2014/07/03/sql-agent-job-server-centralized-job-server/","title":"SQL Agent Job server.(Centralized job server)"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 DECLARE @ObjName varchar(255) SET @ObjName = \u0026#39;abc\u0026#39; SELECT c.usecounts , c.cacheobjtype , c.objtype , c.size_in_bytes , t.text , p.query_plan , DB_NAME(p.dbid) AS DBNAME , p.encrypted FROM sys.dm_exec_cached_plans c CROSS APPLY sys.dm_exec_sql_text(plan_handle) t CROSS APPLY sys.dm_exec_query_plan (plan_handle) p WHERE usecounts \u0026gt; 1 and t.text like \u0026#39;%\u0026#39;+@ObjName+\u0026#39;%\u0026#39; AND t.text not like \u0026#39;%sys.dm_exec_cached_plans%\u0026#39; GO --DBCC FREEPROCCACHE (plan_handle); --ex) DBCC FREEPROCCACHE (0x05000C00F01C44754021DDDA040000000000000000000000); GO ","date":"2014-07-02T11:51:34-07:00","permalink":"/2014/07/02/drop-certain-query-plan/","title":"Drop certain query plan"},{"content":"Email send when @objName has data. @objName should include DB name as well. Ex) @objName = ‘DBA.dbo.vw_Job_Status’\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 CREATE PROCEDURE [dbo].[dmp_send_email_HTML_format] @objName VARCHAR(255) , @Subject VARCHAR(255) , @PreDescription varchar(8000) = NULL , @Recipients VARCHAR(8000) , @importance VARCHAR(255) = \u0026#39;High\u0026#39; , @profile VARCHAR(255) = \u0026#39;Public_Profile\u0026#39; --eMail profile name as BEGIN SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED /* Return value @r 10001 : object is wrong 10002 : column is wrong 0 : Done or Nodata. */ DECLARE @tableHTML NVARCHAR(max) , @HTML_TH NVARCHAR(max) , @HTML_TD NVARCHAR(max) , @sql NVARCHAR(4000) , @param NVARCHAR(4000) , @DBName VARCHAR(255) , @rowcnt INT , @r INT DECLARE @tbl_datacheck TABLE (i INT) SET @DBName = PARSENAME(@objName,3) SET @r = -1 IF OBJECT_ID(@objName) IS NULL BEGIN SET @r = 10001 GOTO ERROR; END IF @DBName = \u0026#34; OR @DBName IS NULL BEGIN SET @DBName = DB_NAME() END SET @sql = \u0026#39;select top 1 1 from \u0026#39;+ @objName INSERT INTO @tbl_datacheck EXEC (@sql) SET @rowcnt = @@ROWCOUNT IF @rowcnt \u0026lt;=0 BEGIN SET @r = 0 GOTO ERROR; END IF OBJECT_ID(\u0026#39;tempdb.dbo.#tbl_column\u0026#39;) IS NOT NULL DROP TABLE #tbl_column CREATE TABLE #tbl_column (idx INT IDENTITY(1,1), NAME VARCHAR(255)) set @sql = \u0026#39; INSERT #tbl_column SELECT name FROM \u0026#39;+@DBName+\u0026#39;.SYS.syscolumns WHERE ID = OBJECT_ID(@objName) ORDER BY colorder \u0026#39; set @param = \u0026#39; @objName varchar(255) \u0026#39; exec sp_executesql @sql, @param, @objName SET @rowcnt = @@ROWCOUNT --PRINT @rowcnt IF @rowcnt = 0 BEGIN SET @r = 10002 GOTO ERROR; END SELECT @HTML_TH = CAST ((SELECT th = isnull(NAME,\u0026#39; \u0026#39;) FROM #tbl_column FOR XML PATH(\u0026#39;\u0026#39;), TYPE ) AS NVARCHAR(MAX) ) --print @HTML_TH SET @HTML_TD = \u0026#39;\u0026#39; SELECT @HTML_TD = @HTML_TD + \u0026#39;td = isnull(\u0026#39;+NAME+\u0026#39;,\u0026#39;\u0026#39; \u0026#39;\u0026#39;), \u0026#39;\u0026#39;\u0026#39;\u0026#39;, \u0026#39; FROM #tbl_column SET @HTML_TD = SUBSTRING(@HTML_TD, 1, LEN(@HTML_TD)-1) SET @sql = \u0026#39;SELECT @HTML_TD = CAST ((SELECT \u0026#39;+ REPLACE(@HTML_TD,\u0026#39;\u0026#39;,\u0026#39;\u0026#39;\u0026#39;\u0026#39;) +\u0026#39; FROM \u0026#39;+@objName+\u0026#39; FOR XML PATH(\u0026#39;\u0026#39;tr\u0026#39;\u0026#39;), TYPE ) AS NVARCHAR(MAX) ) \u0026#39; --PRINT @sql EXEC sp_executesql @sql, N\u0026#39; @HTML_TD NVARCHAR(MAX) OUTPUT \u0026#39;, @HTML_TD OUTPUT --PRINT @HTML_TD set @Recipients = isnull(@Recipients,\u0026#39;NowcomDBDevTeam@nowcom.com\u0026#39;) set @subject = @@servername +\u0026#39; -- \u0026#39; + convert(varchar(255), getdate(), 101) + \u0026#39; \u0026#39; + convert(varchar(5), getdate(), 108)+\u0026#39; \u0026#39; + @Subject SET @tableHTML = \u0026#39; h1{ font-size:17px; } body{ font-size:15px; } table{ border-collapse:collapse; border:1px solid black; font-size:12px; } table th{ font:bold; border:1px solid black; padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px; background-color:lightblue; font-size:12px; } table td{ border:1px solid black; padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:1px font-size:12px; } \u0026#39;+ @subject +\u0026#39; \u0026#39;+ ISNULL(@PreDescription,\u0026#34;) + \u0026#39; \u0026#39; + @HTML_TD set @tableHTML = @tableHTML + \u0026#39; \u0026#39; SELECT @tableHTML = \u0026#39;From Server :\u0026#39; + ISNULL(@@SERVERNAME, \u0026#34;) + char(13) + char(10) + ISNULL(@tableHTML, \u0026#34;); EXEC msdb.dbo.sp_send_dbmail @profile_name = @profile , @body_format = \u0026#39;HTML\u0026#39; , @recipients = @Recipients , @importance = @importance , @copy_recipients =\u0026#34; , @subject = @subject , @body = @tableHTML IF @@error 0 BEGIN RAISERROR(\u0026#39;Error in dmp_send_email_HTML_format. Failed to send Database Mail.\u0026#39;, 16, 1); END RETURN 0 ERROR: return @r END Go ","date":"2014-06-30T11:45:39-07:00","permalink":"/2014/06/30/alert-email-sending/","title":"Alert email sending"},{"content":"http://msdn.microsoft.com/en-us/library/cc441928.aspx\n1 2 3 4 SELECT * FROM Table1 WHERE (ABS(CAST( (BINARY_CHECKSUM(*) * RAND()) as int)) % 100) \u0026lt; 10 -- Percent SELECT * FROM Table1 TABLESAMPLE (1 percent) ORDER BY NEWID()\n","date":"2014-06-12T13:20:35-07:00","permalink":"/2014/06/12/selecting-rows-randomly-from-a-large-table/","title":"Selecting Rows Randomly from a Large Table"},{"content":" [SQLAgent – Job invocation engine] : execute it based on active schedule and job at scheduled time. 1 2 exec sp_executesql N\u0026#39;UPDATE msdb.dbo.sysjobactivity SET run_requested_date = DATEADD(ms, -DATEPART(ms, GetDate()), GetDate()), run_requested_source = CONVERT(sysname, @P1), queued_date = NULL, start_execution_date = NULL, last_executed_step_id = NULL, last_executed_step_date = NULL, stop_execution_date = NULL, job_history_id = NULL, next_scheduled_run_date = NULL WHERE job_id = @P2 and session_id = @P3\u0026#39;,N\u0026#39;@P1 int,@P2 uniqueidentifier,@P3 int\u0026#39;,1,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39;,14 [SQLAgent – Job Manager] : Update start time. Check Permission. Get Jobstep. And execute each step 1 2 3 4 5 6 7 8 9 10 11 12 13 14 exec sp_executesql N\u0026#39;DECLARE @startExecutionDate DATETIME SET @startExecutionDate = msdb.dbo.agent_datetime(@P1, @P2) UPDATE msdb.dbo.sysjobactivity SET start_execution_date = @startExecutionDate WHERE job_id = @P3 and session_id = @P4\u0026#39;,N\u0026#39;@P1 int,@P2 int,@P3 uniqueidentifier,@P4 int\u0026#39;,20140611,144430,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39;,14 exec sp_executesql N\u0026#39;EXECUTE msdb.dbo.sp_sqlagent_has_server_access @login_name = @P1\u0026#39;,N\u0026#39;@P1 nvarchar(128)\u0026#39;,N\u0026#39;sa\u0026#39; exec sp_executesql N\u0026#39;EXECUTE msdb.dbo.sp_help_jobstep @job_id = @P1\u0026#39;,N\u0026#39;@P1 uniqueidentifier\u0026#39;,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39; EXECUTE @retval = sp_verify_job_identifiers \u0026#39;@job_name\u0026#39;, \u0026#39;@job_id\u0026#39;, @job_name OUTPUT, @job_id OUTPUT, \u0026#39;NO_TEST\u0026#39; --Execute each step [SQLAgent – TSQL JobStep(Job 0x…) or SSIS JobStep(Job 0x…)] : Execute each step.\n[SQLAgent – Job Manager] : Update job history and status.\n1 2 exec sp_executesql N\u0026#39;EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory @job_id = @P1, @step_id = @P2, @sql_message_id = @P3, @sql_severity = @P4, @run_status = @P5, @run_date = @P6, @run_time = @P7, @run_duration = @P8, @operator_id_emailed = @P9, @operator_id_netsent = @P10, @operator_id_paged = @P11, @retries_attempted = @P12, @session_id = @P13, @message = @P14\u0026#39;,N\u0026#39;@P1 uniqueidentifier,@P2 int,@P3 int,@P4 int,@P5 int,@P6 int,@P7 int,@P8 int,@P9 int,@P10 int,@P11 int,@P12 int,@P13 int,@P14 nvarchar(4000)\u0026#39;,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39;,1,0,0,1,20140611,144430,0,0,0,0,0,14,N\u0026#39;Executed as user: NT AUTHORITY\\NETWORK SERVICE. The step succeeded.\u0026#39; [SQLAgent – Update job activity] – Update next schedule. 1 2 exec sp_executesql N\u0026#39;DECLARE @nextScheduledRunDate DATETIME SET @nextScheduledRunDate = msdb.dbo.agent_datetime(@P1, @P2) UPDATE msdb.dbo.sysjobactivity SET next_scheduled_run_date = @nextScheduledRunDate WHERE session_id = @P3 AND job_id = @P4\u0026#39;,N\u0026#39;@P1 int,@P2 int,@P3 int,@P4 uniqueidentifier\u0026#39;,20140611,144440,14,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39; [SQLAgent – Job Manager] – Update last run time 1 2 3 4 exec sp_executesql N\u0026#39;UPDATE msdb.dbo.sysjobservers SET last_run_date = @P1, last_run_time = @P2, last_run_outcome = @P3, last_outcome_message = @P4, last_run_duration = @P5 WHERE (job_id = @P6) AND (server_id = 0)\u0026#39;,N\u0026#39;@P1 int,@P2 int,@P3 int,@P4 nvarchar(4000),@P5 int,@P6 uniqueidentifier\u0026#39;,20140611,144430,1,N\u0026#39;The job succeeded. The Job was invoked by Schedule 30 (test). The last step to run was step 1 (step01).\u0026#39;,0,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39; exec sp_executesql N\u0026#39;EXECUTE msdb.dbo.sp_sqlagent_log_jobhistory @job_id = @P1, @step_id = @P2, @sql_message_id = @P3, @sql_severity = @P4, @run_status = @P5, @run_date = @P6, @run_time = @P7, @run_duration = @P8, @operator_id_emailed = @P9, @operator_id_netsent = @P10, @operator_id_paged = @P11, @retries_attempted = @P12, @session_id = @P13, @message = @P14\u0026#39;,N\u0026#39;@P1 uniqueidentifier,@P2 int,@P3 int,@P4 int,@P5 int,@P6 int,@P7 int,@P8 int,@P9 int,@P10 int,@P11 int,@P12 int,@P13 int,@P14 nvarchar(4000)\u0026#39;,\u0026#39;676BBCD8-CE4A-4ADA-8215-A4E9276D6BBB\u0026#39;,0,0,0,1,20140611,144430,0,0,0,0,0,14,N\u0026#39;The job succeeded. The Job was invoked by Schedule 30 (test). The last step to run was step 1 (step01).\u0026#39; Done.\n","date":"2014-06-11T15:07:55-07:00","permalink":"/2014/06/11/sql-server-job-agent-execution-job-sequence/","title":"SQL Server Job Agent - Invoke job sequence."},{"content":"I used long time ago.\nTo find the it again, I spent a lot of time.\nThis is really helpful to identify XML parentID and currentID.\nOpenXML support it.\nMetaproperty attribute Description @mp:id Provides system-generated, document-wide identifier of the DOM node (element, attribute, and so on). This ID is guaranteed to refer to the same XML node as long as the document is not reparsed.An XML ID of 0 indicates that the element is a root element. Its parent XML ID is NULL. @mp:localname Stores the local part of the name of the node. It is used with prefix and namespace URI (Uniform Resource Identifier) to name element or attribute nodes. @mp:namespaceuri Provides the namespace URI of the current element. If the value of this attribute is NULL, no namespace is present @mp:prefix Stores the namespace prefix of the current element name.If no prefix is present (NULL) and a URI is given, indicates that the specified namespace is the default namespace. If no URI is given, no namespace is attached. @mp:prev Stores the previous sibling relative to a node, thereby, providing information about the ordering of elements in the document.@mp:prev contains the XML ID of the previous sibling that has the same parent element. If an element is at the beginning of the sibling list, @mp:prev is NULL. @mp:xmltext This metaproperty is used for processing purposes. Is the textual serialization of the element and its attributes and subelements as used in the overflow handling of OPENXML. Parent metaproperty attribute Description @mp:parentid Corresponds to ../@mp:id @mp:parentlocalname Corresponds to ../@mp:localname @mp:parentnamespacerui Corresponds to ../@mp:namespaceuri @mp:parentprefix Corresponds to ../@mp:prefix http://technet.microsoft.com/en-us/library/aa226531%28v=sql.80%29.aspx\nhttp://technet.microsoft.com/en-us/library/ms178088.aspx\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 DECLARE @X XML, @h INT SET @X = \u0026#39;\u0026lt;root\u0026gt;\u0026lt;element\u0026gt;test\u0026lt;/element\u0026gt;\u0026lt;element\u0026gt;test2\u0026lt;/element\u0026gt;\u0026lt;/root\u0026gt;\u0026#39; EXEC sp_xml_preparedocument @h OUTPUT, @x select @h SELECT * FROM OPENXML (@h, \u0026#39;./root/element\u0026#39;,8) WITH ( id bigint \u0026#39;@mp:id\u0026#39; , parentid bigint \u0026#39;@mp:parentid\u0026#39; , element varchar(255) \u0026#39;.\u0026#39; ) EXEC sp_xml_removedocument @h ","date":"2014-05-19T17:13:20-07:00","permalink":"/2014/05/19/openxml-parentid/","title":"OpenXML parentID"},{"content":"Login failed for user \\User1′. Reason: Token-based server access validation failed with an infrastructure error. Check\nhttp://blogs.msdn.com/b/sqlserverfaq/archive/2010/10/27/troubleshooting-specific-login-failed-error-messages.aspx\n","date":"2014-04-02T11:34:43-07:00","permalink":"/2014/04/02/token-based-server-access-validation-failed-with-an-infrastructure-error-error-18456/","title":"Token-based server access validation failed with an infrastructure error, Error: 18456"},{"content":" 1 2 3 4 5 exec sp_rename \u0026#39;usp_test\u0026#39;,\u0026#39;uspp_test\u0026#39; select text from sys.syscomments where id=object_id(\u0026#39;uspp_test\u0026#39;) The text column is still showing as “create procedure usp_test”.\nIt breaks to run “sp_refreshsqlmodule”\nInvalid object name ‘dbo.uspp_test’.\nTo be able to resolve it, run again “alter procedure ” statement.\n","date":"2013-08-05T16:55:46-07:00","permalink":"/2013/08/05/sp_rename-will-not-change-sys-syscomments-table-definition/","title":"sp_rename will not change sys.syscomments table definition."},{"content":" 1 http://www.sqlservercentral.com/articles/ETL/69339/ ","date":"2013-05-08T11:13:49-07:00","permalink":"/2013/05/08/excel-import-using-xml-and-t-sql/","title":"Excel import using XML and T-SQL"},{"content":"http://www.sqlskills.com/blogs/paul/misconceptions-around-tf-1118/\n[Edit 2012:] 4a) What is Paul’s recommendation for using trace flag 1118? Everyone should turn it on, on all instances of SQL Server, from SQL Server 2000 onwards. There’s no down-side to having it turned on.\nhttp://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-1230-tempdb-should-always-have-one-data-file-per-processor-core/\nBut there’s now even better guidance, and what I also recommend. At PASS in 2011, my good friend Bob Ward, who’s the top guy in SQL Product Support, espoused a new formula: if you have less than 8 cores, use #files = #cores. If you have more than 8 cores, use 8 files and if you’re seeing in-memory contention, add 4 more files at a time.\nhttp://technet.microsoft.com/library/Cc966545\nUse TF-1118. Under this trace flag SQL Server allocates full extents to each tempdb object, thereby eliminating the contention on SGAM page. This is done at the expense of some waste of disk space in tempdb. This trace flag has been available since SQL Server 2000. With improvements in tempdb object caching in SQL Server 2005, there should be significantly less contention in allocation structures. If you see contention in SGAM pages, you may want to use this trace flag. Cached tempdb objects may not always be available. For example, cached tempdb objects are destroyed when the query plan with which they are associated is recompiled or removed from the procedure cache.\n","date":"2013-03-12T10:36:53-07:00","permalink":"/2013/03/12/tempdb-misconceptions-around-tf-1118/","title":"TempDB Misconceptions around TF 1118"},{"content":"http://msdn.microsoft.com/en-us/library/ms189110%28v=sql.90%29.aspx\nOnly SQLCHAR is allowed for fmt files if the file storage type is Char.\n1 Data files that are stored in character format use char as the file storage type. Therefore, for character data files, SQLCHAR is the only data type that appears in a format file.\n2 You cannot bulk import data into text, ntext, and image columns that have DEFAULT values.\nAdditional Considerations for File Storage Types\nWhen you bulk export data from an instance of SQL Server to a data file:\nYou can always specify char as the file storage type. If you enter a file storage type that represents an invalid implicit conversion, bcp fails; for example, though you can specify int for smallint data, if you specify smallint for int data, overflow errors result. When noncharacter data types such as float, money, datetime, or int are stored as their database types, the data is written to the data file in the SQL Server native format. Comments (archived from WordPress) Exterminator in MD · 2015-03-26\nThank you for some other informative site. The place else could I am getting that type of information written in such a perfect manner? I have a venture that I’m just now operating on, and I have been at the look out for such information.\n","date":"2013-03-07T11:57:30-08:00","permalink":"/2013/03/07/bulk-load-data-conversion-error-overflow-sqlint-bcp/","title":"Bulk load data conversion error (overflow) SQLINT (BCP)"},{"content":"Please don’t put 1.5 time of Physical memory.\nLess amount is better for SQL server if you have a x64 machine and enough physical memory.\nhttp://support.microsoft.com/kb/889654/en-us\nhttp://blogs.msdn.com/b/buckwoody/archive/2010/06/29/the-windows-page-file-and-sql-server.aspx\nhttp://www.brentozar.com/archive/2009/11/christian-bolton-on-sql-server-memory/\nhttp://blogs.technet.com/b/askperf/archive/2007/12/14/what-is-the-page-file-for-anyway.aspx\nhttp://www.brentozar.com/archive/2008/03/sql-server-2005-setup-checklist-part-1-before-the-install/\n","date":"2013-02-27T16:32:37-08:00","permalink":"/2013/02/27/paging-file-for-sql-server/","title":"Paging file for SQL server"},{"content":"http://sqlservermct.wordpress.com/2011/10/07/backup-database-to-disk-n%E2%80%98nul%E2%80%99-%E2%80%93-and-misconceptions/\nVeeam can truncate log base on some option.\nhttp://www.veeam.com/vmware-backup/help-center/v6_1/hyperv/index.html?vmware_replica_guest_processing.htm\nIt make backup chain broken. When they perform truncate log, you can see 2 of the log like this.\nSQL VSS is normal behavior to create SnapShot on disk. But, Veeam Backup and replication with truncate log isn’t good option to manage database.\nI recommend that do not enable truncate log on Veeam replication manager.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 select top 10 * from msdb.dbo.backupset where is_snapshot=1 --It\u0026#39;s due to SQL VSS. --Program_Name : \u0026#34;Microsoft SQL Server VSS Writer\u0026#34; --ex) --BACKUP DATABASE [DBNAME] TO VIRTUAL_DEVICE=\u0026#39;{4C5C20F9-FE32-4FCA-BE43-FFFFFFFFFFFF}1\u0026#39; WITH SNAPSHOT,BUFFERCOUNT=1,BLOCKSIZE=1024 select top 10 * from msdb.dbo.backupmediafamily where physical_device_name=\u0026#39;NUL\u0026#39; --It\u0026#39;s due to Veeam. --Program_Name : \u0026#34;Veeam Backup and Replication\u0026#34; --ex) --BACKUP LOG [DBNAME] TO DISK = \u0026#39;NUL\u0026#39; ","date":"2013-01-04T17:48:14-08:00","permalink":"/2013/01/04/backup-database-to-disk-nnul/","title":"BACKUP DATABASE TO DISK = N‘NUL’"},{"content":" newsequentialid() http://msdn.microsoft.com/en-us/library/ms189786%28v=sql.100%29.aspx\nThis is one of the function to generate sequence GUID to reduce fragmentation.\nBut, it’s not grantee uniqueness. It’s wrapped by windows function UuidCreateSequential, http://msdn.microsoft.com/en-us/library/aa379322%28VS.85%29.aspx.\nCreates a GUID that is greater than any GUID previously generated by this function on a specified computer since Windows was started. After restarting Windows, the GUID can start again from a lower range, but is still globally unique. When a GUID column is used as a row identifier, using NEWSEQUENTIALID can be faster than using the NEWID function. This is because the NEWID function causes random activity and uses fewer cached data pages. Using NEWSEQUENTIALID also helps to completely fill the data and index pages.\nuniqueidentifier sorting. http://sqlblog.com/blogs/alberto_ferrari/archive/2007/08/31/how-are-guids-sorted-by-sql-server.aspx\nuniqueidentifier converting 1 2 3 4 5 6 7 SELECT CONVERT(uniqueidentifier, 0x000102030405060708090A0B0C0D0E0F) UNION ALL SELECT CONVERT(uniqueidentifier, 0x00000000000000000123456789ABCDEF) UNION ALL SELECT CONVERT(uniqueidentifier, 0x000000000123456789ABCDEF00000000) UNION ALL SELECT CONVERT(UNIQUEIDENTIFIER, \u0026#39;00000000-0123-4567-89AB-CDEF00000000\u0026#39;) ","date":"2013-01-02T09:33:24-08:00","permalink":"/2013/01/02/unique-sequence-identifier-newsequentialid/","title":"uniqueidentifier : GUID in SQL"},{"content":"simon@simonsql.com\nTuning, Consulting and all DB related questions.\n","date":"2012-12-20T00:10:05-08:00","permalink":"/2012/12/20/contact-information/","title":"Contact information"},{"content":"http://www.sommarskog.se/grantperm.html\n","date":"2012-12-05T16:03:29-08:00","permalink":"/2012/12/05/cross-database-access/","title":"Cross-Database Access"},{"content":"http://www.veeam.com/vmware-backup/help-center/v6_1/hyperv/index.html?vmware_replica_guest_processing.htm\nPlease select this one, “Do not truncate logs”.\n——————————————————————————————————\nUse the Truncation logs section to define the scenario of transaction log handing:\n•Select Truncate logs on successful backup only if you want Veeam Backup \u0026amp; Replication to trigger truncation of logs only after the job is finished successfully. In this case, Veeam agent will wait for the replication to complete, and then will trigger truncation of transaction logs. If truncation of transaction logs is not possible for some reason, the logs will remain untouched in the VM guest OS till the next start of the Veeam agent.\n•Select Truncate logs immediately if you want Veeam Backup \u0026amp; Replication to trigger truncation of logs in any case, no matter whether the job finishes successfully or fails.\n•Select Do not truncate logs if you do not want Veeam Backup \u0026amp; Replication to truncate logs at all. This option is recommended if you are using another tool to perform guest-level replication and this tool maintains consistency of the database state. In such scenario, truncation of logs with Veeam Backup \u0026amp; Replication will break the guest-level replication chain and cause it to fall out of sync.\n———————————————————————————————————————–\nWhen I checked backup list, it’s truncate log like this.\nBACKUP LOG xxxDB TO DISK = ‘NUL’\nSo, physical_device_name is presented as ‘NUL’.\n1 2 3 4 5 6 7 8 select bs.* , bf.* from msdb.dbo.dbo.backupset bs join msdb.dbo.[backupmediafamily] bf on bs.media_set_id = bf.media_set_id where 1=1 and database_name=\u0026#39;MyDB\u0026#39; and type=\u0026#39;L\u0026#39; order by backup_start_date desc ","date":"2012-11-29T13:29:21-08:00","permalink":"/2012/11/29/backup-chain-is-broken-due-to-veeam-backup-configuration-doesnt-setup-properly/","title":"Backup chain is broken due to Veeam Backup configuration improperly."},{"content":"http://blogs.msdn.com/b/sqlcat/archive/2008/08/05/microsoft-sql-server-database-snapshots-and-synonyms.aspx\n","date":"2012-10-26T10:56:08-07:00","permalink":"/2012/10/26/snapshot-and-synonyms/","title":"Snapshot and Synonyms"},{"content":"http://www.brentozar.com/archive/2011/08/dedicated-admin-connection-why-want-when-need-how-tell-whos-using/\nhttp://msdn.microsoft.com/en-us/library/ms178068%28v=sql.105%29.aspx\nTo use in SSMS please follow up those steps.\nEnable SQL Server Browser. Many of case for Network-Related error message is due to this reason.\nPlease use “Database Engine Query“, File\u0026gt;New\u0026gt; Database Engine query This is keyword.\nDo not open using object explorer since DAC does NOT support multiple sessions.\nAdd “ADMIN:” in front of server name ADMIN:localhost\n","date":"2012-10-26T10:14:58-07:00","permalink":"/2012/10/26/dedicated-administrator-connection/","title":"Dedicated Administrator Connection"},{"content":"http://www.simple-talk.com/sql/database-administration/handling-deadlocks-in-sql-server/ http://blogs.msdn.com/b/bartd/archive/2008/09/24/today-s-annoyingly-unwieldy-term-intra-query-parallel-thread-deadlocks.aspx http://social.msdn.microsoft.com/Forums/en/sqldatabaseengine/thread/ea1a28eb-1ff3-41ca-af22-7110347627bf\n","date":"2012-10-09T17:12:15-07:00","permalink":"/2012/10/09/deadlock-handling/","title":"DeadLock handling"},{"content":"http://msdn.microsoft.com/en-us/library/ms179296%28v=sql.105%29.aspx\n","date":"2012-09-27T11:41:38-07:00","permalink":"/2012/09/27/errorhandling/","title":"Errorhandling"},{"content":"http://msdn.microsoft.com/en-us/library/ms164086.aspx\nSeverity level Description 0-9 Informational messages that return status information or report errors that are not severe. The Database Engine does not raise system errors with severities of 0 through 9. 10 Informational messages that return status information or report errors that are not severe. For compatibility reasons, the Database Engine converts severity 10 to severity 0 before returning the error information to the calling application. 11-16 Indicate errors that can be corrected by the user. 11 Indicates that the given object or entity does not exist. 12 A special severity for queries that do not use locking because of special query hints. In some cases, read operations performed by these statements could result in inconsistent data, since locks are not taken to guarantee consistency. 13 Indicates transaction deadlock errors. 14 Indicates security-related errors, such as permission denied. 15 Indicates syntax errors in the Transact-SQL command. 16 Indicates general errors that can be corrected by the user. 17-19 Indicate software errors that cannot be corrected by the user. Inform your system administrator of the problem. 17 Indicates that the statement caused SQL Server to run out of resources (such as memory, locks, or disk space for the database) or to exceed some limit set by the system administrator. 18 Indicates a problem in the Database Engine software, but the statement completes execution, and the connection to the instance of the Database Engine is maintained. The system administrator should be informed every time a message with a severity level of 18 occurs. 19 Indicates that a nonconfigurable Database Engine limit has been exceeded and the current batch process has been terminated. Error messages with a severity level of 19 or higher stop the execution of the current batch. Severity level 19 errors are rare and must be corrected by the system administrator or your primary support provider. Contact your system administrator when a message with a severity level 19 is raised. Error messages with a severity level from 19 through 25 are written to the error log. 20-24 Indicate system problems and are fatal errors, which means that the Database Engine task that is executing a statement or batch is no longer running. The task records information about what occurred and then terminates. In most cases, the application connection to the instance of the Database Engine may also terminate. If this happens, depending on the problem, the application might not be able to reconnect.Error messages in this range can affect all of the processes accessing data in the same database and may indicate that a database or object is damaged. Error messages with a severity level from 19 through 24 are written to the error log. 20 Indicates that a statement has encountered a problem. Because the problem has affected only the current task, it is unlikely that the database itself has been damaged. 21 Indicates that a problem has been encountered that affects all tasks in the current database, but it is unlikely that the database itself has been damaged. 22 Indicates that the table or index specified in the message has been damaged by a software or hardware problem.Severity level 22 errors occur rarely. If one occurs, run DBCC CHECKDB to determine whether other objects in the database are also damaged. The problem might be in the buffer cache only and not on the disk itself. If so, restarting the instance of the Database Engine corrects the problem. To continue working, you must reconnect to the instance of the Database Engine; otherwise, use DBCC to repair the problem. In some cases, you may have to restore the database. If restarting the instance of the Database Engine does not correct the problem, then the problem is on the disk. Sometimes destroying the object specified in the error message can solve the problem. For example, if the message reports that the instance of the Database Engine has found a row with a length of 0 in a nonclustered index, delete the index and rebuild it. 23 Indicates that the integrity of the entire database is in question because of a hardware or software problem.Severity level 23 errors occur rarely. If one occurs, run DBCC CHECKDB to determine the extent of the damage. The problem might be in the cache only and not on the disk itself. If so, restarting the instance of the Database Engine corrects the problem. To continue working, you must reconnect to the instance of the Database Engine; otherwise, use DBCC to repair the problem. In some cases, you may have to restore the database. 24 Indicates a media failure. The system administrator may have to restore the database. You may also have to call your hardware vendor. ","date":"2012-09-21T13:32:43-07:00","permalink":"/2012/09/21/raiserror-database-engine-error-severities/","title":"RAISERROR : Database Engine Error Severities"},{"content":"FIX: You receive error 605 and error 824 when you run a query that inserts data into a temporary table in SQL Server http://support.microsoft.com/kb/960770\nTrace flag 4199 is added to control multiple query optimizer changes previously made under multiple trace flags http://support.microsoft.com/kb/974006\n","date":"2012-09-20T10:02:10-07:00","permalink":"/2012/09/20/could-not-continue-scan-with-nolock-due-to-data-movement/","title":"Could not continue scan with NOLOCK due to data movement"},{"content":"http://msdn.microsoft.com/en-us/library/ms174205.aspx\n","date":"2012-09-12T10:40:14-07:00","permalink":"/2012/09/12/useful-sql-server-management-studio-keyboard-shortcuts/","title":"Useful SQL Server Management Studio Keyboard Shortcuts"},{"content":"http://smartypeeps.blogspot.com/2006/11/t-sql-script-to-find-nw-port-of-sql.html\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 declare @Server as varchar(128) declare @KeyToInterogate as varchar(200) declare @Version as varchar (512) declare @PortNumber as varchar(8) set @Server = @@ServerName set @Version = left(@@Version, 38) set @KeyToInterogate = \u0026#39;SOFTWARE\\MICROSOFT\\MSSQLSERVER\\MSSQLSERVER\\SUPERSOCKETNETLIB\\TCP\u0026#39; if charindex(\u0026#39;\\\u0026#39;,@@ServerName) \u0026gt; 0 begin set @KeyToInterogate = \u0026#39;SOFTWARE\\Microsoft\\Microsoft SQL Server\\\u0026#39; set @KeyToInterogate = @KeyToInterogate + substring(@@ServerName,charindex(\u0026#39;\\\u0026#39;,@@ServerName) + 1,len(@@ServerName) - charindex(\u0026#39;\\\u0026#39;,@@ServerName)) set @KeyToInterogate = @KeyToInterogate + \u0026#39;\\MSSQLServer\\SuperSocketNetLib\\Tcp\u0026#39; end exec xp_regread @rootkey = \u0026#39;HKEY_LOCAL_MACHINE\u0026#39;, @key = @KeyToInterogate, @value_name = \u0026#39;TcpPort\u0026#39;, @value = @PortNumber output exec master..xp_regread \u0026#39;HKEY_LOCAL_MACHINE\u0026#39; , \u0026#39;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\u0026#39; , \u0026#39;ProductName\u0026#39; exec master..xp_regread \u0026#39;HKEY_LOCAL_MACHINE\u0026#39; , \u0026#39;SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\u0026#39; , \u0026#39;CSDVersion\u0026#39; SELECT @@servername AS hostname , SERVERPROPERTY(\u0026#39;Edition\u0026#39;) AS Edition , ISNULL(SERVERPROPERTY(\u0026#39;InstanceName\u0026#39;),\u0026#39;\u0026#39;) AS InstanceName , SERVERPROPERTY(\u0026#39;MachineName\u0026#39;) AS MachineName , SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;) AS ProductVersion , SERVERPROPERTY(\u0026#39;ProductLevel\u0026#39;) as ProductLevel , @@VERSION , CASE WHEN CONVERT(VARCHAR(255),SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;)) LIKE \u0026#39;8.0%\u0026#39; THEN \u0026#39;2000\u0026#39; WHEN CONVERT(VARCHAR(255),SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;)) LIKE \u0026#39;9.0%\u0026#39; THEN \u0026#39;2005\u0026#39; WHEN CONVERT(VARCHAR(255),SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;)) LIKE \u0026#39;10.0%\u0026#39; THEN \u0026#39;2008\u0026#39; WHEN CONVERT(VARCHAR(255),SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;)) LIKE \u0026#39;10.5%\u0026#39; THEN \u0026#39;2008 R2\u0026#39; END , cast(@PortNumber as varchar) , (select top 1 local_net_address from sys.dm_exec_connections where local_net_address is not null) as IP_address SELECT SERVERPROPERTY(\u0026#39;ProductVersion\u0026#39;) AS ProductVersion, SERVERPROPERTY(\u0026#39;ProductLevel\u0026#39;) AS ProductLevel, SERVERPROPERTY(\u0026#39;Edition\u0026#39;) AS Edition, SERVERPROPERTY(\u0026#39;EngineEdition\u0026#39;) AS EngineEdition; ","date":"2012-08-20T18:40:33-07:00","permalink":"/2012/08/20/server-information-include-port/","title":"server information include port #"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 use msdb --select top 10 * from backupfile --select top 10 * from backupmediaset --select top 10 * from backupmediafamily declare @sql nvarchar(4000) if exists(select OBJECT_NAME(id) from syscolumns where name=\u0026#39;compressed_backup_size\u0026#39;) begin set @sql = \u0026#39; select top 1 @@servername as servername, case when sum(compressed_backup_size)convert(varchar(8),getdate()-30,112) group by convert(varchar(8), backup_start_date, 112) order by sum(backup_size) desc \u0026#39; end else begin set @sql = \u0026#39; select top 1 @@servername as servername, \u0026#39;\u0026#39;N\u0026#39;\u0026#39; compressed_backup , convert(numeric(10,2),sum(backup_size/1024/1024/1024.0)) as [backup_size(GB)] from msdb.dbo.backupset with(nolock) where backup_start_date\u0026gt;convert(varchar(8),getdate()-30,112) group by convert(varchar(8), backup_start_date, 112) order by sum(backup_size) desc \u0026#39; end exec(@sql) ","date":"2012-08-20T18:36:17-07:00","permalink":"/2012/08/20/backup-size-check-including-compression-backup/","title":"Backup Size check including compression backup"},{"content":"http://msdn.microsoft.com/en-us/library/aa237436%28v=sql.80%29.aspx\nhttp://msdn.microsoft.com/en-us/library/ms151762.aspx\nhttp://www.google.com/url?sa=t\u0026rct=j\u0026q=\u0026esrc=s\u0026source=web\u0026cd=5\u0026ved=0CGUQFjAE\u0026url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2Fd%2F9%2F4%2Fd948f981-926e-40fa-a026-5bfcf076d9b9%2FReplicationAndDBM.docx\u0026ei=_6wqUJeCEdH1iQKl_YHADg\u0026usg=AFQjCNGQ4F4LY3sb4jwY4iIvqUqCmT8NqA\u0026sig2=NUGwh6APmlhMy5N89jW9HA\u0026cad=rja\n1. Most importance is Pull subscription. Consider Pull or Anonymous Subscriptions The Distribution or Merge Agent runs on the Distributor for push subscriptions, and on Subscribers for pull or anonymous subscriptions. Using pull or anonymous subscriptions can increase performance by moving Distribution or Merge Agent processing from the Distributor to Subscribers.\nYou can also offload agent processing by using Remote Agent Activation. Agent processing can be moved to the Subscriber for push subscriptions and to the Distributor for pull subscriptions. Administration of the agent still takes place at the Distributor for push subscriptions and at the Subscriber for pull subscriptions. For more information, see Remote Agent Activation.\nAnonymous subscriptions, which are especially useful for Internet applications, do not require that information about the Subscriber be stored in the distribution database at the Distributor for transactional replication and reduces the storage of information about the Subscriber in the publishing database for merge replication. This reduces the resource demands on the Publisher and Distributor because they do not have to maintain information about anonymous Subscribers.\nAnonymous subscriptions are a special category of pull subscriptions. In regular pull subscriptions, the Distribution or Merge Agent runs at the Subscriber (thereby reducing the resource demands on the Distributor), but still stores information at the Publisher. When a publication supports anonymous subscriptions, the publication is configured to always have a snapshot ready for new Subscribers.\nFor transactional replication, this means that every time the Snapshot Agent runs, a new snapshot will be generated. Typically, a snapshot is not generated if there are no new Subscribers waiting for a snapshot or no Subscriber needs to be reinitialized at the time the Snapshot Agent is run. So while anonymous Subscribers can reduce the resource demands at the Distributor, the tradeoff is that a snapshot is generated more often. With merge replication, a new snapshot is always generated when the Snapshot Agent runs regardless of the type of subscriptions supported by the publication.\n2. Change default distribution agent setup. http://msdn.microsoft.com/en-us/library/ms147328.aspx\n3. Performance test\nhttp://msdn.microsoft.com/en-us/library/dd263442.aspx\nPerformance Indicators Test Scenarios SQL Server 2005 on Windows Server 2003 (A) SQL Server 2008 on Windows Server 2008 (B) Performance Gains or Losses [(A-B)/B]*100 CPU Utilization (%) All 15% 15% 0% Memory All 99% 99% 0% Push Replication 1-GB 226.12 (minutes) 110.42 (minutes) 104.78% 1,000,000 1k character records Pull Replication 1-GB 174.87 (minutes) 12.5 (minutes) 1298.96% 1,000,000 1k character records Linked Server 10-MB 107.6 (minutes) 113.6 (minutes) –5.28% 10,000 1k character records Push Replication 112-MB 247.07 (minutes) 59.13 (minutes) 317.84% 100,000 varbinary (max) records Pull Replication Records 112-MB 223.18 (minutes) 1.95 (minutes) 11345.13% 100,000 varbinary (max) records Snapshot Replication 11.3-GB 10,100,000 1k records Not tested 22.75 (minutes) Comparison not available ","date":"2012-08-14T14:48:27-07:00","permalink":"/2012/08/14/remote-replicationlong-distance-replication/","title":"Remote Replication(Long distance Replication)"},{"content":"http://support.microsoft.com/kb/321822\nexec sp_addpublication_snapshot , @publisher_security_mode = 0 , @publisher_login = N’sql_Replication_user’ , @publisher_password = N’sql_Replication_user_password’\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 exec ReplicationDB.sys.sp_addlogreader_agent @job_login = null , @job_password = null , @publisher_security_mode = 0 , @publisher_login = N\u0026#39;sql_Replication_user\u0026#39; , @publisher_password = N\u0026#39;sql_Replication_user_password\u0026#39; GO exec sp_addpublication_snapshot @publication = N\u0026#39;TestPublication\u0026#39; , @frequency_type = 1 , @frequency_interval = 0 , @frequency_relative_interval = 0 , @frequency_recurrence_factor = 0 , @frequency_subday = 0 , @frequency_subday_interval = 0 , @active_start_time_of_day = 0 , @active_end_time_of_day = 235959 , @active_start_date = 0 , @active_end_date = 0 , @job_login = null , @job_password = null , @publisher_security_mode = 0 , @publisher_login = N\u0026#39;sql_Replication_user\u0026#39; , @publisher_password = N\u0026#39;sql_Replication_user_password\u0026#39; ","date":"2012-08-14T12:59:24-07:00","permalink":"/2012/08/14/replication-in-non-trusted-domains/","title":"Replication in Non-Trusted Domains"},{"content":"Click to access NetVault%20LiteSpeed%20for%20SQL%20Server%20-%20User%20Guide.pdf\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 EXEC master.dbo.xp_backup_database @database = \u0026#39;database_name\u0026#39; (, @filename = \u0026#39;backup_file_name\u0026#39;) [,...n] [, @nowrite = 0 | 1 ] [, @desc = \u0026#39;backup_description\u0026#39;] [, @backupname = \u0026#39;backupset_name\u0026#39;] [, @threads = 1..32] [, @init = 0 | 1 ] [, @LSECompatible = 1] [, @mirror = \u0026#39;mirror_backup_file_name\u0026#39;] [,...n] [, @doubleclick = 0 | 1 ] [,( @encryptionkey = \u0026#39;encryption_key\u0026#39;| @jobp = \u0026#39;encrypted_key\u0026#39; ) ] [, @cryptlevel = \u0026#39;encryption_level\u0026#39;] [, @read_write_filegroups = 0 | 1 ] [, @file = \u0026#39;logical_file_name\u0026#39;] [,...n] [, @filegroup = \u0026#39;logical_filegroup_name\u0026#39;] [,...n] [, @priority = -1 | 0 | 1 | 2 ] [, @with = \u0026#39;additional_with_parameters\u0026#39;] [,...n] [, ( @retaindays = 0..99999 | @expiration = \u0026#39;date\u0026#39; ) ] [, @logging = 0 | 1 | 2 ] [, @olrmap = 0 | 1 ] [, @affinity = 0..2147483648] [, @throttle = 1..100] [, @ioflag = \u0026#39;DISK_RETRY_COUNT=n\u0026#39;] [, @ioflag = \u0026#39;DISK_RETRY_WAIT=n\u0026#39;] [, @comment = \u0026#39;comment\u0026#39;] [, @buffercount = \u0026#39;buffer_count\u0026#39;] [, @maxtransfersize = \u0026#39;maximum_transfer_size\u0026#39;] [, @adaptivecompression = \u0026#39;speed\u0026#39; | \u0026#39;size\u0026#39; ] [, @compressionlevel = \u0026#39;compresssion_level\u0026#39;] [, @attachedfile = \u0026#39;pathname\u0026#39;] [, @tsmclientnode = \u0026#39;TSM_client_node\u0026#39;] [, @tsmclientownerpwd = \u0026#39;TSM_client_owner_password\u0026#39;] [, @tsmobject = \u0026#39;TSM_object\u0026#39;] [, @tsmconfigfile = \u0026#39;TSM_configuration_file\u0026#39;] [, @tsmmanagementclass = \u0026#39;TSM_management_class\u0026#39;] [, @tsmarchive = 0 |1 ] [, @verify = 0 | 1 ] [, @returndetails = 0 |1 ] EXEC master.dbo.xp_backup_log @database = \u0026#39;database_name\u0026#39; (, @filename = \u0026#39;backup_file_name\u0026#39;) [,...n] [, @nowrite = 0 | 1 ] [, @desc = \u0026#39;backup_description\u0026#39;] [, @backupname = \u0026#39;backupset_name\u0026#39;] [, @threads = 1..32] [, @init = 0 | 1 ] [, @LSECompatible = 1] [, @mirror = \u0026#39;mirror_backup_file_name\u0026#39;] [,...n] [, @doubleclick = 0 | 1 ] [, ( @encryptionkey = \u0026#39;encryption_key\u0026#39; | @jobp = \u0026#39;encrypted_key\u0026#39; ) ] [, @cryptlevel = \u0026#39;encryption_level\u0026#39;] [, @file = \u0026#39;logical_file_name\u0026#39;] [,...n] [, @filegroup = \u0026#39;logical_filegroup_name\u0026#39;] [,...n] [, @priority = -1 | 0 | 1 | 2 ] [, @with = \u0026#39;additional_with_parameters\u0026#39;] [,...n] [, ( @retaindays = 0..99999 | @expiration = \u0026#39;date\u0026#39; ) ] [, @logging = 0 | 1 | 2 ] [, @ioflag = \u0026#39;DISK_RETRY_COUNT=n\u0026#39;] [, @ioflag = \u0026#39;DISK_RETRY_WAIT=n\u0026#39;] [, @affinity = 0..2147483648] [, @throttle = 1..100] [, @comment = \u0026#39;comment\u0026#39;] [, @buffercount = \u0026#39;buffer_count\u0026#39;] [, @maxtransfersize = \u0026#39;maximum_transfer_size\u0026#39;] [, @adaptivecompression = \u0026#39;size\u0026#39; | \u0026#39;speed\u0026#39; ] [, @compressionlevel = \u0026#39;compresssion_level\u0026#39;] [, @attachedfile = \u0026#39;pathname\u0026#39;] [, @tsmclientnode = \u0026#39;TSM_client_node\u0026#39;] [, @tsmclientownerpwd = \u0026#39;TSM_client_owner_password\u0026#39;] [, @tsmobject = \u0026#39;TSM_object\u0026#39;] [, @tsmconfigfile = \u0026#39;TSM_configuration_file\u0026#39;] [, @tsmmanagementclass = \u0026#39;TSM_management_class\u0026#39;] [, @tsmarchive = 0 |1 ] [, @verify = 0 | 1 ] [, @returndetails = 0 | 1 ] ","date":"2012-08-14T12:49:58-07:00","permalink":"/2012/08/14/quest-lightspeed-backup-t-sql/","title":"Quest LiteSpeed Compressed Backup T-SQL"},{"content":"https://sqlserverperformance.wordpress.com/tag/dmv-queries/\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 select convert(varchar(19), getdate(), 121) as date_time , db_name(df.database_id) as DatabaseName , f.name as FileLogicalName , f.filename , case when num_of_reads+num_of_writes\u0026gt;0 then io_stall/(num_of_reads+num_of_writes) else 0 end as \u0026#39;ms/io\u0026#39; , case when num_of_reads\u0026gt;0 then io_stall_read_ms/num_of_reads else 0 end as \u0026#39;ms/Read io\u0026#39; , case when num_of_writes\u0026gt;0 then io_stall_write_ms/num_of_writes else 0 end as \u0026#39;ms/Write io\u0026#39; from sys.dm_io_virtual_file_stats(null,null) as df join sys.sysaltfiles as f on f.dbid= df.database_id and f.fileid = df.file_id --where df.database_id in(DB_ID(\u0026#39;msdb\u0026#39;), DB_ID(\u0026#39;TempDB\u0026#39;)) where case when num_of_reads+num_of_writes\u0026gt;0 then io_stall/(num_of_reads+num_of_writes) else 0 end \u0026gt;50 or case when num_of_reads\u0026gt;0 then io_stall_read_ms/num_of_reads else 0 end \u0026gt;50 or case when num_of_writes\u0026gt;0 then io_stall_write_ms/num_of_writes else 0 end \u0026gt;50 order by 5 desc ","date":"2012-08-14T12:42:53-07:00","permalink":"/2012/08/14/disk-io-response-time-in-sql/","title":"Disk IO Response time In SQL"},{"content":"\nMany of people may be using this kind of logic to return array to a table using number table.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 --Table \u0026#34;Num\u0026#34; is simply has a sequence number. CREATE FUNCTION [dbo].[fn_Split](@str NVARCHAR(max), @splitValue VARCHAR(10)=\u0026#39;,\u0026#39;) RETURNS TABLE AS RETURN ( SELECT N-LEN(REPLACE(LEFT(@str, N), @splitValue, \u0026#34;)) + 1 AS POS , CONVERT(NVARCHAR(4000), SUBSTRING(@str, N, CHARINDEX(@splitValue, @str+@splitValue, N) -- N)) AS ELEMENT FROM dbo.NUM WHERE N \u0026lt;= LEN(@str) AND SUBSTRING(@splitValue+@str, N, LEN(@splitValue))= @splitValue AND SUBSTRING(@str, N, CHARINDEX(@splitValue, @str+@splitValue, N) -- N)\u0026#34; ) GO select * from dbo.fn_Split(‘1,2,3,4’)\nBut, this kind of logic can’t support a multi-dimensional array.\nHere is another way to implement it. For example a|1,ab|2,abc|3,abcd|4,abcde|5\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 CREATE FUNCTION [dbo].[func_split_multiDimensional] ( @ss VARCHAR(max) , @delimeter_row VARCHAR(10) = \u0026#39;|\u0026#39; , @delimeter_col VARCHAR(10) = \u0026#39;-\u0026#39; , @col_cnt int ) RETURNS @COL_TMP TABLE ( ROWNO INT , COL1 VARCHAR(max) , COL2 VARCHAR(max) , COL3 VARCHAR(max) , COL4 VARCHAR(max) , COL5 VARCHAR(max) , COL6 VARCHAR(max) , COL7 VARCHAR(max) , COL8 VARCHAR(max) , COL9 VARCHAR(max) , COL10 VARCHAR(max) ) AS -- ============================================= -- Author:\tSIMON CHO -- Create date: 2010.08.30 -- Description:\tMultiDimensional array -- ============================================= BEGIN DECLARE @X XML\nSET @SS = ‘’+@ss+\u0026rsquo;’ SET @SS = REPLACE(@ss, @delimeter_row, ‘’) SET @SS = REPLACE(@ss, @delimeter_col, ‘’)\nSET @X = CAST(@SS AS XML)\nINSERT INTO @COL_TMP\nSELECT (ROWNO-1)/@col_cnt + 1 AS ROWNO ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 0 THEN COL END)) AS COL1 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 1 THEN COL END)) AS COL2 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 2 THEN COL END)) AS COL3 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 3 THEN COL END)) AS COL4 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 4 THEN COL END)) AS COL5 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 5 THEN COL END)) AS COL6 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 6 THEN COL END)) AS COL7 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 7 THEN COL END)) AS COL8 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 8 THEN COL END)) AS COL9 ,MAX((CASE (ROWNO-1)%@col_cnt WHEN 9 THEN COL END)) AS COL10 FROM ( SELECT ROW_NUMBER() OVER(ORDER BY X.COL.value(‘@N’, ‘INT’)) AS ROWNO , X.COL.value(‘.’, ‘VARCHAR(100)’) AS COL FROM @X.nodes(‘/rt/r/c’) X(COL) ) X GROUP BY (ROWNO-1)/@col_cnt ORDER BY (ROWNO-1)/@col_cnt\nRETURN END\nGO\nSELECT * FROM dbo.[func_split_multiDimensional](‘a|1,ab|2,abc|3,abcd|4,abcde|5′,’,’,’|’,2)\n","date":"2012-07-18T18:54:11-07:00","permalink":"/2012/07/18/array-to-table-for-multi-dimensional/","title":"Array to table for multi dimensional"},{"content":"http://www.ssmstoolspack.com/\nHome\n","date":"2012-07-11T14:53:57-07:00","permalink":"/2012/07/11/ssms-tool-pack-and-other-useful-free-tools/","title":"SSMS tool pack and other useful free tools"},{"content":"Since, msdb.dbo.sysjobhistory has run_duration as INT data type. Need to convert to find out actual job start time and end time.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 create function [dbo].[fn_get_job_start_datetime] (@run_date int, @run_time int) returns datetime as begin return convert(datetime,rtrim(@run_date)) + (@run_time*9 + @run_time%10000*6 + @run_time%100*10) / 216e4 end go create function [dbo].[fn_get_job_end_datetime] (@run_date int, @run_time int, @run_duration int) returns datetime as begin if @run_duration\u0026lt;0 -- some of replication job has minus(-) value. set @run_duration = 99999999 return convert(datetime,rtrim(@run_date)) + (@run_time*9 + @run_time%10000*6 + 25*@run_duration) / 216e4 end go select top 10 j.name as job_name , h.run_date , h.run_time , h.run_duration , h.run_status , dbo.fn_get_job_start_datetime(h.run_date, h.run_time) as job_start_datetime , dbo.fn_get_job_end_datetime(h.run_date, h.run_time, h.run_duration) as job_end_datetime from msdb.dbo.sysjobs j join msdb.dbo.sysjobhistory h on j.job_id = h.job_id ","date":"2012-06-05T17:01:57-07:00","permalink":"/2012/06/05/find-out-sql-job-start-time-and-end-time/","title":"Find out sql job start time and end time"},{"content":"http://msdn.microsoft.com/en-us/library/ms189797.aspx\nXACT_STATE returns the following values.\nReturn value Meaning 1 The current request has an active user transaction. The request can perform any actions, including writing data and committing the transaction. 0 There is no active user transaction for the current request. -1 The current request has an active user transaction, but an error has occurred that has caused the transaction to be classified as an uncommittable transaction. The request cannot commit the transaction or roll back to a savepoint; it can only request a full rollback of the transaction. The request cannot perform any write operations until it rolls back the transaction. The request can only perform read operations until it rolls back the transaction. After the transaction has been rolled back, the request can perform both read and write operations and can begin a new transaction.When a batch finishes running, the Database Engine will automatically roll back any active uncommittable transactions. If no error message was sent when the transaction entered an uncommittable state, when the batch finishes, an error message will be sent to the client application. This message indicates that an uncommittable transaction was detected and rolled back. Both the XACT_STATE and @@TRANCOUNT functions can be used to detect whether the current request has an active user transaction.\n@@TRANCOUNT cannot be used to determine whether that transaction has been classified as an uncommittable transaction.\nXACT_STATE cannot be used to determine whether there are nested transactions.\nhttp://msdn.microsoft.com/en-us/library/ms181299.aspx\nROLLBACK TRANSACTION without a savepoint_name or transaction_name rolls back to the beginning of the transaction. When nesting transactions, this same statement rolls back all inner transactions to the outermost BEGIN TRANSACTION statement.\nIn both cases, ROLLBACK TRANSACTION decrements the @@TRANCOUNT system function to 0. ROLLBACK TRANSACTION savepoint_name does not decrement @@TRANCOUNT.\nROLLBACK TRANSACTION cannot reference a savepoint_name in distributed transactions started either explicitly with BEGIN DISTRIBUTED TRANSACTION or escalated from a local transaction.\nA transaction cannot be rolled back after a COMMIT TRANSACTION statement is executed, except when the COMMIT TRANSACTION is associated with a nested transaction that is contained within the transaction being rolled back. In this instance, the nested transaction will also be rolled back, even if you have issued a COMMIT TRANSACTION for it.\nWithin a transaction, duplicate savepoint names are allowed, but a ROLLBACK TRANSACTION using the duplicate savepoint name rolls back only to the most recent SAVE TRANSACTION using that savepoint name.\nPaul recommand doesn’t use Nested Transaction.\nhttp://sqlskills.com/BLOGS/PAUL/post/A-SQL-Server-DBA-myth-a-day-%282630%29-nested-transactions-are-real.aspx\n","date":"2012-04-23T17:03:57-07:00","permalink":"/2012/04/23/xact_state-or-trancount/","title":"XACT_STATE or @@Trancount (To control Nested Transaction)"},{"content":"http://sqlserverpedia.com/blog/sql-server-bloggers/update-statistics-before-or-after-an-index-rebuild/\nhttp://www.sqlskills.com/blogs/paul/post/Search-Engine-QA-10-Rebuilding-Indexes-and-Updating-Statistics.aspx\nAnother good article. http://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html\n","date":"2012-04-11T19:07:42-07:00","permalink":"/2012/04/11/index-update-vs-statistics-update/","title":"Index rebuild vs. Statistics update"},{"content":"Index rebuild and Statistics update http://weblogs.sqlteam.com/billg/archive/2011/02/08/sql-server-scripts-i-use.aspx\nLogging issue Version : SQL2008 R2\nhttp://msdn.microsoft.com/en-us/library/ms191484%28v=sql.105%29.aspx\nIndex operation Full Bulk-logged Simple ALTER INDEX REORGANIZE Fully logged Fully logged Fully logged ALTER INDEX REBUILD Fully logged Minimally logged Minimally logged CREATE INDEX Fully logged Minimally logged Minimally logged DBCC INDEXDEFRAG Fully logged Fully logged Fully logged DBCC DBREINDEX Fully logged Minimally logged Minimally logged DROP INDEX Index page deallocation is fully logged; new heap rebuild, if applicable, is fully logged. Index page deallocation is fully logged; new heap rebuild, if applicable, is minimally logged. Index page deallocation is fully logged; new heap rebuild, if applicable, is minimally logged. You need to change Bulk-logged operation when starting the index rebuild.\nEven if Bulk-logged, “Alter index reoranize” is fully logged. So, please change the schedule of Trasanction log backup frequently.\nIndex rebuild http://sqlfool.com/2010/04/index-defrag-script-v4-0/\nStatistics update http://weblogs.sqlteam.com/billg/archive/2010/12/02/script-to-update-statistics-with-time-window.aspx\n","date":"2012-04-11T18:57:14-07:00","permalink":"/2012/04/11/index-operation/","title":"Index operation"},{"content":"error message would be like this.\nMsg 7391, Level 16, State 2, Procedure xxx, Line xxx The operation could not be performed because OLE DB provider “SQLNCLI10” for linked server “LinkedServer B” was unable to begin a distributed transaction.\nIf you don’t care about distributed transaction for the remote exec and insert statement, you can simply change the option for the linked server.\n1 2 sp_serveroption ServerName, \u0026#39;remote proc transaction promotion\u0026#39;, \u0026#39;false\u0026#39; Comments (archived from WordPress) Simon Cho · 2013-05-21\nThis issue isn’t related with Database. It’s due to HTML standard. You may need to check “www.w3schools.com” to figure out what it is.\n","date":"2012-04-05T20:22:08-07:00","permalink":"/2012/04/05/distributed-transaction-insert-exec-error/","title":"distributed transaction insert exec error"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 use distribution go select distinct @@SERVERNAME as Distributor , db_name(db_id()) as Distributor_DB , srv.srvname publication_server , a.publisher_db , p.publication publication_name , a.article , a.destination_object , p.retention , ss.srvname subscription_server , s.subscriber_db from MSArticles a join MSpublications p on a.publication_id = p.publication_id join MSsubscriptions s on p.publication_id = s.publication_id join master..sysservers ss on s.subscriber_id = ss.srvid join master..sysservers srv on srv.srvid = p.publisher_id join MSdistribution_agents da on da.publisher_id = p.publisher_id and da.subscriber_id = s.subscriber_id ORDER BY p.retention ","date":"2012-03-13T15:18:22-07:00","permalink":"/2012/03/13/pull-out-replication-all-articles-and-server-information/","title":"[replication] all articles and server information"},{"content":"3rd part tool isn’t working well.\nex) Litespeed\nSQL server 2000-2008R2 working fine.\nSum(Calculate 1 day backup set including transaction log)\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 use msdb --select top 10 * from backupfile --select top 10 * from backupmediaset --select top 10 * from backupmediafamily declare @sql nvarchar(4000) if exists(select OBJECT_NAME(id) from syscolumns where name=\u0026#39;compressed_backup_size\u0026#39;) begin set @sql = \u0026#39; select top 1 @@servername as servername , case when sum(compressed_backup_size)convert(varchar(8),getdate()-30,112) group by convert(varchar(8), backup_start_date, 112) order by sum(backup_size) desc \u0026#39; end else begin set @sql = \u0026#39; select top 1 @@servername as servername, \u0026#39;\u0026#39;N\u0026#39;\u0026#39; compressed_backup , convert(numeric(10,2),sum(backup_size/1024/1024/1024.0)) as [backup_size(GB)] from msdb.dbo.backupset with(nolock) where backup_start_date\u0026gt;convert(varchar(8),getdate()-30,112) group by convert(varchar(8), backup_start_date, 112) order by sum(backup_size) desc \u0026#39; end exec(@sql) ","date":"2012-03-08T18:52:49-08:00","permalink":"/2012/03/08/size-1-day-backup-size/","title":"Size 1 day backup size"},{"content":"http://technet.microsoft.com/en-us/library/cc966539.aspx\nhttp://searchsqlserver.techtarget.com/tip/15-SQL-Server-replication-tips-in-15-minutes\nhttp://www.sql-server-performance.com/2005/replication-tuning/\n","date":"2012-02-23T21:48:33-08:00","permalink":"/2012/02/23/replication-performance-tuning/","title":"Replication performance tuning"},{"content":"Master DB rebuild and change check list\nbackup login script http://support.microsoft.com/kb/918992\nbackup linked server script\nDetach databases.\nMaster rebuild whatever option\ncreate another instance and attach : make sure same file location of system DBs, msdb, master, tempdb(you can fix it later). single mode rebuild : http://blogs.msdn.com/b/psssql/archive/2008/08/29/how-to-rebuild-system-databases-in-sql-server-2008.aspx When you rebuild or attach master DB, you should know about sa password from original instance.\nSQL service pack update if different version.\nAttach databases\nIf you move master database from other service, you should drop unnecessary databases. run #1 login script only for necessary account(s).\nchange sa password if you want\nchange master key with force option\nhttp://simonsql.com/2012/02/23/an-error-occurred-during-decryption/\nALTER SERVICE MASTER KEY FORCE REGENERATE\n11. change server name \u0026lt;http://msdn.microsoft.com/en-us/library/ms143799.aspx\u0026gt; ```sql use master declare @srvname varchar(255), @new_srvname varchar(255) set @srvname = @@servername set @new_srvname = \u0026#39;new hostname\u0026#39; --your computer hostname exec sp_dropserver @srvname exec sp_addserver @new_srvname, local go change server option if you want to change : sp_configure min max memory ad hoc query e.t.c. ","date":"2012-02-23T18:14:45-08:00","permalink":"/2012/02/23/master-rebuild-and-change-check-list/","title":"Master rebuild and change check list"},{"content":"I guess, you had a problem on Master database. After changed you got linked server error like this.\n“An error occurred during decryption.”\nThe reason why login mapping password can decrypt due to master key changed. So, you need to generate again master key with force option.\nhttp://support.microsoft.com/kb/914261\nALTER SERVICE MASTER KEY FORCE REGENERATE\n","date":"2012-02-23T18:00:41-08:00","permalink":"/2012/02/23/an-error-occurred-during-decryption/","title":"An error occurred during decryption"},{"content":"http://weblogs.sqlteam.com/mladenp/archive/2010/10/12/sql-server-ndash-undelete-a-table-and-restore-a-single.aspx\n","date":"2012-02-01T23:25:22-08:00","permalink":"/2012/02/01/sql-server-undelete-a-table-and-restore-a-single-table-from-backup/","title":"SQL Server - Undelete a Table and Restore a Single Table from Backup"},{"content":"http://blogs.msdn.com/b/sqltips/archive/2008/07/02/converting-from-hex-string-to-varbinary-and-vice-versa.aspx\nSQL2005\n1 2 3 4 5 6 7 8 9 10 11 12 -- Convert hexstring value in a variable to varbinary: declare @hexstring varchar(max); set @hexstring = \u0026#39;abcedf012439\u0026#39;; select cast(\u0026#39;\u0026#39; as xml).value(\u0026#39;xs:hexBinary( substring(sql:variable(\u0026#34;@hexstring\u0026#34;), sql:column(\u0026#34;t.pos\u0026#34;)) )\u0026#39;, \u0026#39;varbinary(max)\u0026#39;) from (select case substring(@hexstring, 1, 2) when \u0026#39;0x\u0026#39; then 3 else 0 end) as t(pos) go -- Convert binary value in a variable to hexstring: declare @hexbin varbinary(max); set @hexbin = 0xabcedf012439; select \u0026#39;0x\u0026#39; + cast(\u0026#39;\u0026#39; as xml).value(\u0026#39;xs:hexBinary(sql:variable(\u0026#34;@hexbin\u0026#34;) )\u0026#39;, \u0026#39;varchar(max)\u0026#39;); go SQL2008\n1 2 3 4 5 6 7 8 9 10 11 declare @hexstring varchar(max); set @hexstring = \u0026#39;0xabcedf012439\u0026#39;; select CONVERT(varbinary(max), @hexstring, 1); set @hexstring = \u0026#39;abcedf012439\u0026#39;; select CONVERT(varbinary(max), @hexstring, 2); go declare @hexbin varbinary(max); set @hexbin = 0xabcedf012439; select CONVERT(varchar(max), @hexbin, 1), CONVERT(varchar(max), @hexbin, 2); go Comments (archived from WordPress) Thorkil Johansen · 2012-03-08\nAfter searching for a charhex to int for hours, you gave me the inspiration. Thanx trom Thorkil Copenhagen\n","date":"2012-01-31T17:33:58-08:00","permalink":"/2012/01/31/converting-from-hex-string-to-varbinary-and-vice-versa/","title":"Converting from hex string to varbinary and vice versa"},{"content":"http://support.microsoft.com/kb/886839\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 CREATE FUNCTION dbo.fn_convertnumericlsntobinary( @numericlsn numeric(25,0) ) returns binary(10) AS BEGIN -- Declare components to be one step larger than the intended type -- to avoid sign overflow problems. For example, convert(smallint, convert(numeric(25,0),65535)) will fail but convert(binary(2), -- convert(int,convert(numeric(25,0),65535))) will give the -- intended result of 0xffff. declare @high4bytelsncomponent bigint, @mid4bytelsncomponent bigint, @low2bytelsncomponent int select @high4bytelsncomponent = convert(bigint, floor(@numericlsn / 1000000000000000)) select @numericlsn = @numericlsn - convert(numeric(25,0), @high4bytelsncomponent) * 1000000000000000 select @mid4bytelsncomponent = convert(bigint,floor(@numericlsn / 100000)) select @numericlsn = @numericlsn - convert(numeric(25,0), @mid4bytelsncomponent) * 100000 select @low2bytelsncomponent = convert(int, @numericlsn) return convert(binary(4), @high4bytelsncomponent) + convert(binary(4), @mid4bytelsncomponent) + convert(binary(2), @low2bytelsncomponent) END Comments (archived from WordPress) Daniel Adeniji · 2015-12-10\nSimon:\nCan you please let me know if using this function will help any closer to converting fn_fbLog Log to datetime.\nThanks,\nDaniel Adeniji\nSimon Cho · 2015-12-28\nHi Daniel,\nLSN itself doesn’t mean about time. This is only for transaction sequence number. https://technet.microsoft.com/en-us/library/ms190411(v=sql.105).aspx\nWhen you run fn_dblog(null,null), you can find out the “Begin time” and “End time” in the LOP_BEGIN_XACT” and “LOP_COMMIT_XACT” operation. So that, you can join with transaction ID and find out corresponding transaction begin time and end time.\nThis convert function is for lookup backupset table since it’s not numeric (25,0) format.\nThanks,\nSimon\nDaniel Adeniji · 2015-12-28\nThanks, Daniel\n","date":"2012-01-29T00:58:21-08:00","permalink":"/2012/01/29/lsn-convert/","title":"LSN Convert"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 SELECT top 100 * FROM fn_dump_dblog ( DEFAULT, DEFAULT, DEFAULT, DEFAULT, \u0026#39;c:\\backup\\aaaa_backup.trn\u0026#39;, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT ) where operation = \u0026#39;LOP_DELETE_ROWS\u0026#39; ","date":"2012-01-28T00:57:36-08:00","permalink":"/2012/01/28/fn_dump_dblog/","title":"fn_dump_dblog"},{"content":"Microsoft Certified Master on Microsoft SQL Server 2008\nhttp://www.microsoft.com/learning/en/us/certification/master-sql.aspx\nBrent Ozar article – SQL MCM\nhttp://www.brentozar.com/sql-mcm/\nBrent Ozar – SQL MCM: The Exams\nhttp://www.brentozar.com/archive/2010/04/sql-mcm-exams/\nMCM Prep week : Interview with Joe Sack\nhttp://www.brentozar.com/archive/2010/02/mcm-prep-week-interview-with-joe-sack/\nSQLSoldier MCM bloging\nhttp://www.sqlsoldier.com/wp/tag/mcm\nThe Master Blog\nhttp://blogs.technet.com/b/themasterblog/\nSQLskills SQL Server Online Training – Links and Study Aids\nhttp://sqlskills.com/mcm.asp\nSQLskills Free Online MCM Training\nhttp://sqlskills.com/T_MCMVideos.asp\nPre-Reading List(Lots of list)\nhttps://dynamicevents.emeetingsonline.com/emeetings/dynamicevents/290/MCM_SQL2008_Pre-reading_v3.pdf\nOn-Disk-Structures\nhttp://www.sqlskills.com/BLOGS/PAUL/category/On-Disk-Structures.aspx\nSQL Server 2008 Microsoft Certified Master (MCM) Readiness Videos\nhttp://technet.microsoft.com/en-us/sqlserver/ff977043.aspx\n","date":"2011-12-27T19:25:55-08:00","permalink":"/2011/12/27/all-about-mcm/","title":"All about MCM"},{"content":"Trace Flag 610 SQL Server 2008 introduces trace flag 610, which controls minimally logged inserts into indexed tables. The trace flag can be turned on by using one of the following methods;\nAdding to the SQL Server startup parameters. For more information, see (http://msdn.microsoft.com/en-us/library/ms345416.aspx) in SQL Server Books Online. Running This enables the trace flag for a specific session. This is useful if you want to enable 610 for only a subset of load scenarios on the instance, and it applies only to the Transact-SQL connection that issues it. Use turns on the trace flag for all connections to the server until it is turned off or until the next server restart. For more information about using DBCC to enable trace flags, see (http://msdn.microsoft.com/en-us/library/ms187329.aspx) in SQL Server Books Online. Before you start using this trace flag, be aware of the limitation described in the previous section.\nNot every row inserted in a cluster index with trace flag 610 is minimally logged. When the bulk load operation causes a new page to be allocated, all of the rows sequentially filling that new page are minimally logged. Rows inserted into pages that are allocated before the bulk load operation occurs are still fully logged, as are rows that are moved as a result of page splits during the load. This means that for some tables, you may still get some fully logged inserts.\nIf trace flag 610 causes minimal logging to occur, you should generally see a performance improvement. But as always with trace flags, make sure you test for your specific environment and workload.\nI/O Impact of Minimal Logging Under Trace Flag 610 When you commit a bulk load transaction that was minimally logged, all of the loaded pages must be flushed to disk before the commit completes. Any flushed pages not caught by an earlier checkpoint operation can create a great deal of random I/O. Contrast this with a fully logged operation, which creates sequential I/O on the log writes instead and does not require loaded pages to be flushed to disk at commit time.\nIf your load scenario is small insert operations on btrees that do not cross checkpoint boundaries, and you have a slow I/O system, using minimal logging can actually slow down insert speeds.\nSummarizing Minimal Logging Conditions To assist you in understanding which bulk load operations will be minimally logged and which will not, the following table lists the possible combinations.\nTable Indexes Rows in table Hints Without TF 610 With TF 610 Concurrent possible Heap Any TABLOCK Minimal Minimal Yes Heap Any None Full Full Yes Heap + Index Any TABLOCK Full Depends (3) No Cluster Empty TABLOCK, ORDER (1) Minimal Minimal No Cluster Empty None Full Minimal Yes (2) Cluster Any None Full Minimal Yes (2) Cluster Any TABLOCK Full Minimal No Cluster + Index Any None Full Depends (3) Yes (2) Cluster + Index Any TABLOCK Full Depends (3) No Table 1: Summary of minimal logging conditions\n(1) If you are using the INSERT … SELECT method, the ORDER hint does not have to be specified, but the rows must be in the same order as the clustered index. If using BULK INSERT the order hint must be used.\n(2) Concurrent loads only possible under certain conditions. See “Bulk Loading with the Indexes in Place”. Also, only rows written to newly allocated pages are minimally logged.\n(3) Depending on the plan chosen by the optimizer, the nonclustered index on the table may either be fully- or minimally logged.\nSummarizing Insert Scenarios The following flow chart helps you solve the different bulk load scenarios.\nFigure 8: Bulk load method decision flowchart\nFullDocument : http://msdn.microsoft.com/en-us/library/dd425070(v=sql.100).aspx\n","date":"2011-12-05T16:06:52-08:00","permalink":"/2011/12/05/minimal-logging-operation-with-traceflag-610/","title":"Minimal logging operation with Traceflag 610"},{"content":"select SUSER_ID(), SUSER_NAME() go select * from server_A.master.dbo.sysobjects go\n(1 row(s) affected) Msg 18452, Level 14, State 1, Line 0 Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.\nexecute as login = ‘sql_admin’ –who has the permission to login the server. go select SUSER_ID(), SUSER_NAME() go select * from server_A.master.dbo.sysobjects go\n(1 row(s) affected)\n(1277 row(s) affected)\nrevert; go select SUSER_ID(), SUSER_NAME() go\n","date":"2011-11-03T18:09:27-07:00","permalink":"/2011/11/03/permission-test-impersonate/","title":"permission test.(impersonate)"},{"content":"Msg 7311, Level 16, State 2, Line 1 Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO” for OLE DB provider “SQLNCLI” for linked server “”. The provider supports the interface, but returns a failure code when it is used.\nYou may receive an error message when you try to run distributed queries from a 64-bit SQL Server client to a linked 32-bit SQL Server http://support.microsoft.com/kb/906954\nAnother method,\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 http://sqlblog.com/blogs/roman_rehak/archive/2009/05/10/issue-with-64-bit-sql-server-using-sql-2000-linked-server.aspx create procedure sp_tables_info_rowset_64 @table_name sysname, @table_schema sysname = null, @table_type nvarchar(255) = null as declare @Result int set @Result = 0 exec @Result = sp_tables_info_rowset @table_name, @table_schema, @table_type go grant execute on sp_tables_info_rowset_64 to public ","date":"2011-11-03T16:20:50-07:00","permalink":"/2011/11/03/sql-2000-linked-server-error-from-x64-machinecannot-obtain-the-schema-rowset-dbschema_tables_info/","title":"SQL 2000 linked server error from x64 machine(Cannot obtain the schema rowset “DBSCHEMA_TABLES_INFO”)"},{"content":"Technical Resource Center http://www.vmware.com/resources/techresources/\n","date":"2011-11-01T12:10:46-07:00","permalink":"/2011/11/01/vmware-tech-pdf-files/","title":"vmware tech pdf files."},{"content":"Very good post for Transaction log performance issues.\nhttp://sqlcat.com/sqlcat/b/technicalnotes/archive/2008/12/09/diagnosing-transaction-log-performance-issues-and-limits-of-the-log-manager.aspx\n","date":"2011-10-24T18:52:01-07:00","permalink":"/2011/10/24/diagnosing-transaction-log-performance-issues-and-limits-of-the-log-manager/","title":"Diagnosing Transaction Log Performance Issues and Limits of the Log Manager"},{"content":"$server = New-Object Microsoft.SqlServer.Management.Smo.Server(“localhost”) $scripter = New-Object Microsoft.SqlServer.Management.Smo.Scripter($server) $jobs = $server.JobServer.get_Jobs() | Where-Object {$_.Name -notlike “sys*”} $script = “” foreach($job in $jobs){ $script += $job.Script() + “GO`n” } $script \u0026raquo; “c:\\sqljobs.sql”\nhttp://www.sqlservercentral.com/blogs/sqlservertips/archive/2011/06/23/taking-script-of-sql-server-jobs-for-migration.aspx\nComments (archived from WordPress) Simon Cho · 2011-09-18\nSet-ExecutionPolicy Unrestricted\n","date":"2011-09-18T17:12:43-07:00","permalink":"/2011/09/18/sql-job-migrationpowershall-script/","title":"SQL Job Migration(powershall script)"},{"content":"Recently, I found that one of the DMV return error data when specific case.\nsys.dm_exec_requests return error result of “blocking_session_id” data when CXPACKET is blocked by other session.\nHere is the simulation\nCreate test data (if your server isn’t working as parallelism on #3, you need to increase top count) use test go if object_id(‘test1’) is not null drop table test1 select top 1000000 identity(int, 1,1) idx, c1.* into test1 from sys.syscolumns c1 cross join sys.syscolumns c2 cross join sys.syscolumns c3 go ALTER TABLE dbo.test1 ADD CONSTRAINT PK_test1 PRIMARY KEY CLUSTERED (idx) go Open new Query on your SSMS and Update one record to make lock processing without close the transaction. (Session 1) Use test Go begin transaction update test1 set name=’test update’ where idx=25000 –rollback transaction Open another new Query on your SSMS and run parallelism query.(Session 2) set transaction isolation level read committed exec sp_configure ‘show advanced options’, 1 reconfigure with override exec sp_configure ‘max degree of parallelism’,0 reconfigure with override select @@SPID go select COUNT(*) from test1 where name like ‘%object%’ option (maxdop 0) Before run the query, please see the execution plan to make sure this query is working as parallelism.\nAnd run the query. It should keep running due to open transaction\nCompare sp_who2 result, sys.sysprocesses and sys.dm_exec_requests result. — 53 is the session id of #3 exec sp_who2 53 select spid, blocked from sys.sysprocesseswhere spid=53 select session_id, blocking_session_id, wait_type from sys.dm_exec_requests where session_id=53 Result of sys.dm_exec_requets\nThe reason is that #2 just blocked 1 record to update.\n#3 query is heavy, so it’s running as parallelism.\nBut, one of parallelism query can’t finish it due to blocking process of update lock.\nSo, it’s waiting for updating.\nIn this case, the sys.dm_exec_requests should return blocking session id as 59.\nBut, it returns as 0.\nIt’s error data.\nThanks.\nSimon Cho\nComments (archived from WordPress) Simon Cho · 2011-08-24\nIt’s sql 2005-2008 problem. The simulation was tested on tested SQL 2008 R2 (SP1), 10.50.2500.\nJungsun Kim · 2011-09-16\nThank you for the good information, Simon 🙂\nSimon Cho · 2011-09-17\nWow. Thank you for visiting here.\nSee you in PASS 2011. I’ll be also there.\nSimon\n","date":"2011-08-24T02:56:11-07:00","permalink":"/2011/08/24/111/","title":"sys.dm_exec_requests error for “blocking_session_id”"},{"content":"select h.agent_id , a.name , rm.publication as pub_name , rm.publisher_db as pub_db , a.publisher_database_id as pub_db_id , a.subscriber_db as sub_db , comments , h.time , isnull(rm.cur_latency, 0) as cur_latency , pub_srv.name as pub_srv , sub_srv.name as sub_srv from distribution_svg011.dbo.msdistribution_agents a with(nolock) join distribution_svg011.dbo.MSreplication_monitordata rm with(nolock) on rm.agent_id=a.id join master.sys.servers pub_srv with(nolock) on a.publisher_id = pub_srv.server_id join master.sys.servers sub_srv with(nolock) on a.subscriber_id= sub_srv.server_id cross apply ( select top 1 * From distribution_SVG011.dbo.msdistribution_history with(nolock) where agent_id=a.id order by timestamp desc ) h order by pub_db, pub_name\nComments (archived from WordPress) simonsql · 2011-08-16\nUsually, token based check it best. But, this case you can really quick check current status.\nSimon\n","date":"2011-08-16T23:53:12-07:00","permalink":"/2011/08/16/replication-status-check/","title":"Replication status check"},{"content":" 1 2 3 4 5 6 7 8 9 10 11 12 SELECT ISNULL(b.groupname, \u0026#39;LOG\u0026#39;) AS \u0026#39;File Group\u0026#39; , Name , [Filename] , CONVERT(Decimal(15,2),ROUND(a.Size/128.000,2)) [Currently Allocated Space(MB)] , CONVERT(Decimal(15,2),ROUND(FILEPROPERTY(a.Name,\u0026#39;SpaceUsed\u0026#39;)/128.000,2)) AS [Space Used (MB)] , CONVERT(Decimal(15,2),ROUND((a.Size-FILEPROPERTY(a.Name,\u0026#39;SpaceUsed\u0026#39;))/128.000,2)) AS [Available Space (MB)] , CONVERT(Decimal(15,2),CONVERT(Decimal(15,2),ROUND((a.Size-FILEPROPERTY(a.Name,\u0026#39;SpaceUsed\u0026#39;))/128.000,2))/CONVERT(Decimal(15,2),ROUND(a.Size/128.000,2))*100) FreeSpace_Ratio FROM dbo.sysfiles a (NOLOCK) left outer JOIN sysfilegroups b (NOLOCK) ON a.groupid = b.groupid --ORDER BY b.groupname ","date":"2011-08-04T14:07:51-07:00","permalink":"/2011/08/04/available-file-group-size/","title":"Available File group size"},{"content":"This query can check each table and index And also, if it is partitioning table, it will show up partition # and each partition # size.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 select FILEGROUP_NAME(au.data_space_id) as file_group , o.name , i.index_id , i.name as index_name , au.partition_number , au.size_MB , case when i.data_space_id \u0026gt; 65000 then \u0026#39;Y\u0026#39; else \u0026#39;N\u0026#39; end IsPartitionedTable from ( select object_id, index_id, partition_number, data_space_id , convert(numeric(10,2) , SUM(in_row_data_page_count + lob_used_page_count + row_overflow_used_page_count) * 8/1024.0) size_MB from sys.allocation_units au join sys.dm_db_partition_stats ps on au.container_id = ps.partition_id and au.type=1 group by object_id, index_id, partition_number, data_space_id ) au join sys.indexes i on i.object_id = au.object_id and i.index_id = au.index_id join sys.all_objects o on i.[object_id] = o.[object_id] and o.type=\u0026#39;U\u0026#39; order by 1,2,3,4 Comments (archived from WordPress) Simon Cho · 2012-06-07\nThis is very good to check size of partitioning table for each partitioning group and all other indexes.\n","date":"2011-08-04T14:04:50-07:00","permalink":"/2011/08/04/object_size_per_filegroup/","title":"object size each table and index (update for partitioning table)"},{"content":"select convert(varchar(19), getdate(), 121) as date_time , db_name(df.database_id) as DatabaseName , f.name as FileLogicalName , f.filename , case when num_of_reads+num_of_writes\u0026gt;0 then io_stall/(num_of_reads+num_of_writes) else 0 end as ‘ms/io’ , case when num_of_reads\u0026gt;0 then io_stall_read_ms/num_of_reads else 0 end as ‘ms/Read io’ , case when num_of_writes\u0026gt;0 then io_stall_write_ms/num_of_writes else 0 end as ‘ms/Write io’ from sys.dm_io_virtual_file_stats(null,null) as df join sys.sysaltfiles as f on f.dbid= df.database_id and f.fileid = df.file_id –where df.database_id in(DB_ID(‘db_passport’), DB_ID(‘TempDB’)) where case when num_of_reads+num_of_writes\u0026gt;0 then io_stall/(num_of_reads+num_of_writes) else 0 end \u0026gt;50 or case when num_of_reads\u0026gt;0 then io_stall_read_ms/num_of_reads else 0 end \u0026gt;50 or case when num_of_writes\u0026gt;0 then io_stall_write_ms/num_of_writes else 0 end \u0026gt;50 order by 5 desc\n","date":"2011-08-04T13:55:16-07:00","permalink":"/2011/08/04/disk-io-response-time-check/","title":"Disk IO response time check."},{"content":"This SP is very helpful to troubleshooting concurrent issue.\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 use master go if object_id(\u0026#39;sp_now\u0026#39;) is not null drop procedure sp_now go create procedure [dbo].[sp_now] @session_id int = null ,@xml_on bit = 0 ,@text nvarchar(500) =\u0026#39;\u0026#39; ,@back_on bit = 0 as /*********************************************************************************************** **Object Name: dbo.sp_now ** **Description: Revise sp_who2 ** **Input Parameters: @session_id int = null , @text nvarchar(500) =\u0026#39; , @back_on bit = 0 ** **Return Value: N/A ** **Return Result Set: session info ** **Creator: Simon Cho ** **Create Date: 09/13/2011 ** **Example: exec [sp_now] ** **Change History ** **Change Date\tChanged By\tReason **9/24/2012\tSimon Cho\tquery_plan off, remove text field. **9/25/2012\tSimon Cho\tChange default value @xml_on=0 *************************************************************************************************/ begin set nocount on; set transaction isolation level read uncommitted; select sp.spid as s_id , max(sp.blocked) as BlkBy , substring(max(convert(varchar(23),r.start_time,121)+sp.status), 24, 50) status , rtrim(max(sp.loginame)) as Login , rtrim(ltrim(max(sp.hostname))) as hostname , min(r.start_time) as st_time , convert(numeric(10,2),max(r.total_elapsed_time/1000)/60.0) [run_time(min)] --, r.total_elapsed_time , GETDATE() as current_datetime , max(sp.waittime) as waittime , substring(max(convert(varchar(23),r.start_time,121)+r.wait_type), 24, 50) wait_type , db_name(max(sp.dbid)) as db , substring(max(convert(varchar(23),r.start_time,121)+command), 24, 50) command , max(r.cpu_time) as cpu_time , max(r.reads) as reads , max(r.writes) as writes , max(r.logical_reads) as logical_reads , rtrim(max(sp.program_name)) as program_name , max(c.client_net_address) ip , min(sp.login_time) as login_time , convert(numeric(10,2),max(r.granted_query_memory)/128.0) as granted_query_memory_MB --, t.objectid , OBJECT_NAME(t.objectid, t.dbid) objname , convert(xml,\u0026#39;\u0026lt;?Q--\u0026#39;+CHAR(13)+CHAR(10)+substring(max(case when text like \u0026#39;Fetch%\u0026#39; then substring(text, 1,32) else text end) , (case when (statement_start_offset/2)+1\u0026lt;len(max(case when text like \u0026#39;Fetch%\u0026#39; then substring(text, 1,32) else text end)) then (statement_start_offset/2)+1 else 1 end) , (case statement_end_offset when -1 then datalength(max(case when text like \u0026#39;Fetch%\u0026#39; then substring(text, 1,32) else text end)) else (statement_end_offset- statement_start_offset)/2 +1 end ) ) +CHAR(13)+CHAR(10)+\u0026#39;--?\u0026gt;\u0026#39;) as text_stmt_xml --, max(t.text) as text , case when @xml_on = 1 then (select query_plan from sys.dm_exec_query_plan(max(r.plan_handle))) else convert(xml, \u0026#39;\u0026#39;) end as query_plan from sys.sysprocesses sp with(nolock) join sys.dm_exec_requests r with(nolock) on r.session_id=sp.spid left join sys.dm_exec_connections c with(nolock) on r.connection_id=c.connection_id outer apply sys.dm_exec_sql_text(r.sql_handle) t where 1=1 -- and sp.spid!=@@SPID and case when @session_id is null then 1 else sp.spid end = case when @session_id is null then 1 else @session_id end and case when @text=\u0026#39;\u0026#39; then \u0026#39;1\u0026#39; else text end like case when @text=\u0026#39;\u0026#39; then \u0026#39;1\u0026#39; else \u0026#39;%\u0026#39;+@text+\u0026#39;%\u0026#39; end and case when @back_on = 0 then sp.spid else 51 end \u0026gt; 50 and case when @back_on = 0 then sp.status else \u0026#39;all\u0026#39; end != \u0026#39;background\u0026#39; group by sp.spid , sp.dbid, t.dbid , t.objectid , r.statement_start_offset , r.statement_end_offset , r.transaction_id , c.connection_id , sp.blocked end go --exec sys.sp_MS_marksystemobject \u0026#39;sp_now\u0026#39; exec sp_now Comments (archived from WordPress) Simon Cho · 2011-08-16\nThis query is very useful. Just run it and see the result.\nSimon\n","date":"2011-08-03T17:14:21-07:00","permalink":"/2011/08/03/sp_now2-rewrite/","title":"sp_now : rewrite sp_who2"},{"content":"select FILEGROUP_NAME(i.data_space_id) as file_group\n, o.name\n, i.index_id\n, i.name as index_name\n, s.size_MB\nfrom sys.indexes i\njoin sys.all_objects o\non i.[object_id] = o.[object_id] and o.type=’U’\ncross apply\n(select convert(numeric(10,2),\nSUM(in_row_data_page_count\nlob_used_page_count\nrow_overflow_used_page_count) * 8/1024.0) size_MB\nfrom sys.dm_db_partition_stats where object_id=o.object_id and index_id=i.index_id) s\norder by 1,2,3\n","date":"2011-06-08T17:01:03-07:00","permalink":"/2011/06/08/check-object-list-and-size-in-filegroup/","title":"check object list and size in filegroup"},{"content":"Information about Network Monitor 3 http://support.microsoft.com/kb/933741\nHow to capture network traffic with Network Monitor\nhttp://support.microsoft.com/kb/148942\nMSDN: Network Monitor\nhttp://technet.microsoft.com/en-us/library/cc938655.aspx\nMicrosoft Network Monitor 3.4 http://www.microsoft.com/downloads/en/details.aspx?displaylang=en\u0026FamilyID=983b941d-06cb-4658-b7f6-3088333d062f\nKerberos Error Configuring SQL Server Linked Server for Delegation http://blogs.msdn.com/b/jorgepc/archive/2010/11/30/kerberos-error-configuring-sql-server-linked-server-for-delegation.aspx\n","date":"2011-04-27T20:49:51-07:00","permalink":"/2011/04/27/network-monitor/","title":"Network Monitor"},{"content":"http://support.microsoft.com/kb/811889/en-us\nThis step-by-step article describes how to troubleshoot the most typical sources of the \u0026ldquo;Cannot generate SSPI context\u0026rdquo; error message. You may receive this error message under the following conditions:\nYou are connecting to SQL Server. You are using Integrated Security. Kerberos is used to perform the security delegation. Understanding Kerberos terminology and Service Principal Name The SQL Server driver on a client computer uses integrated security to use the Windows security token of the user account to successfully connect to a computer that is running SQL Server. The Windows security token is delegated from the client to the computer that is running SQL Server. The SQL Server driver performs this delegation when the user’s security token is delegated from one computer to another by using one of the following configurations:\nNTLM over Named Pipes (not using Security Support Provider Interface [SSPI]) NTLM over TCP/IP sockets with SSPI Kerberos over TCP/IP sockets with SSPI Security Support Provider Interface (SSPI) is a set of Windows APIs that permits delegation and mutual authentication over any generic data transport layer, such as TCP/IP sockets. Therefore, SSPI permits a computer that is running a Windows operating system to securely delegate a user security token from one computer to another over any transport layer that can transmit raw bytes of data.\nThe \u0026ldquo;Cannot generate SSPI context\u0026rdquo; error is generated when SSPI uses Kerberos to delegate over TCP/IP and Kerberos cannot complete the necessary operations to successfully delegate the user security token to the destination computer that is running SQL Server.\nWhy Security Support Provider Interface chooses NTLM or Kerberos Kerberos uses an identifier named \u0026ldquo;Service Principal Name\u0026rdquo; (SPN). Consider an SPN as a domain or forest unique identifier of some instance in a network server resource. You can have an SPN for a Web service, for an SQL service, or for an SMTP service. You can also have multiple Web service instances on the same physical computer that has a unique SPN.\nAn SPN for SQL Server is composed of the following elements:\nServiceClass: This identifies the general class of service. This is always MSSQLSvc for SQL Server. Host: This is the fully qualified domain name DNS of the computer that is running SQL Server. Port: This is the port number that the service is listening on. For example, a typical SPN for a computer that is running SQL Server is:\n1 MSSQLSvc/SQLSERVER1.northamerica.corp.mycompany.com:1433 The format of an SPN for a default instance and the format of an SPN for a named instance are not different. The port number is what ties the SPN to a particular instance.\nWhen the SQL Server driver on a client uses integrated security to connect to SQL Server, the driver code on the client tries to resolve the fully qualified DNS of the computer that is running SQL Server by using the WinSock networking APIs. To perform this operation, the driver code calls thegethostbyname and gethostbyaddr WinSock APIs. Even if an IP address or host name is passed as the name of the computer that is running SQL Server, the SQL Server driver tries to resolve the fully qualified DNS of the computer if the computer is using integrated security.\nWhen the SQL Server driver on the client resolves the fully qualified DNS of the computer that is running SQL Server, the corresponding DNS is used to form the SPN for this computer. Therefore, any issues pertaining to how the IP address or host name is resolved to the fully qualified DNS by WinSock may cause the SQL Server driver to create an invalid SPN for the computer that is running SQL Server.\nFor example, the invalid SPNs that the client-side SQL Server driver can form as resolved fully qualified DNS are:\nMSSQLSvc/SQLSERVER1:1433 MSSQLSvc/123.123.123.123:1433 MSSQLSvc/SQLSERVER1.antartica.corp.mycompany.com:1433 MSSQLSvc/SQLSERVER1.dns.northamerica.corp.mycompany.com:1433 When the SQL Server driver forms an SPN that is not valid, authentication still works because the SSPI interface tries to look up the SPN in the Active Directory directory service, and it does not find the SPN. If the SSPI interface does not find the SPN, Kerberos authentication is not performed. At that point, the SSPI layer switches to an NTLM authentication mode and the logon uses NTLM authentication and typically succeeds. If the SQL Server driver forms an SPN that is valid but is not assigned to the appropriate container, it tries to use the SPN but cannot, causing a \u0026ldquo;Cannot generate SSPI context\u0026rdquo; error message. If the SQL Server startup account is a local system account, the appropriate container is the computer name. For any other account, the appropriate container is the SQL Server startup account. Because authentication will try to use the first SPN that it finds, make sure that there are no SPNs assigned to inappropriate containers. In other words, each SPN must be assigned to one and only one container.\nThe key factor that makes Kerberos authentication successful is the valid DNS functionality on the network. You can verify this functionality on the client and the server by using the Ping command-line utility. On the client computer, run the following command to obtain the IP address of the server that is running SQL Server (where the name of the computer that is running SQL Server is SQLServer1):\nping sqlserver1\nTo see if the Ping command-line utility resolves the fully qualified DNS of SQLServer1, run the following command:\nping -a IPAddress\nFor example:\n1 C:\\\u0026gt;ping SQLSERVER1 1 Pinging SQLSERVER1 [123.123.123.123] with 32 bytes of data: 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Ping statistics for 123.123.123.123: 1 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), 1 Approximate round trip times in milli-seconds: 1 Minimum = 0ms, Maximum = 0ms, Average = 0ms 1 C:\\\u0026gt;ping -a 123.123.123.123 1 Pinging SQLSERVER1.northamerica.corp.mycompany.com [123.123.123.123] with 32 bytes of data: 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Reply from 123.123.123.123: bytes=32 time\u0026lt;10ms TTL=128 1 Ping statistics for 123.123.123.123: 1 Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), 1 Approximate round trip times in milli-seconds: 1 Minimum = 0ms, Maximum = 0ms, Average = 0ms 1 C:\\\u0026gt; When the command ping -aIPAddress resolves to the correct fully qualified DNS of the computer that is running SQL Server, the client side resolution is also successful.\nSQL Server Service Principal Name creation This is one of the critical parts of Kerberos and SQL Server interaction. With SQL Server, you can run the SQL Server service under one of the following: a LocalSystem account, a local user account, or a domain user account. When the SQL Server service instance starts, it tries to register its own SPN in Active Directory by using the DsWriteAccountSpn API call. If the call is not successful, the following warning is logged in Event Viewer:\nSource: MSSQLServer EventID: 19011 Description: SuperSocket info: (SpnRegister) : Error 8344.\nFor more information about the DsWriteAccountSpn function, visit the following Microsoft Web site:\nhttp://msdn2.microsoft.com/en-us/library/ms676056.aspx\nSimplified explanation If you run the SQL Server service under the LocalSystem account, the SPN is automatically registered and Kerberos interacts successfully with the computer that is running SQL Server. However, if you run the SQL Server service under a domain account or under a local account, the attempt to create the SPN will fail in most cases because the domain account and the local account do not have the right to set their own SPNs. When the SPN creation is not successful, this means that no SPN is set up for the computer that is running SQL Server. If you test using a domain administrator account as the SQL Server service account, the SPN is successfully created because the domain administrator-level credentials that you must have to create an SPN are present.\nBecause you might not use a domain administrator account to run the SQL Server service (to prevent security risk), the computer that is running SQL Server cannot create its own SPN. Therefore, you must manually create an SPN for your computer that is running SQL Server if you want to use Kerberos when you connect to a computer that is running SQL Server. This is true if you are running SQL Server under a domain user account or under a local user account. The SPN you create must be assigned to the service account of the SQL Server service on that particular computer. The SPN cannot be assigned to the computer container unless the computer that is running SQL Server starts with local system. There must be one and only one SPN, and it must be assigned to the appropriate container. Typically, this is the current SQL Server service account. However, this is the computer account with local system.\nVerify the domain Verify that the domain to which you log on can communicate with the domain to which the computer that is running SQL Server belongs. There must also be proper name resolution in the domain.\nYou must make sure that you can successfully log on to Windows by using the same domain account and password as the startup account of the SQL Server service. For example, the SSPI error may occur in one of the following situations: The domain account is locked out. The password of the account was changed. However, you never restart the SQL Server service after the password was changed. If your logon domain is different from the domain of the computer that is running SQL Server, check the trust relationship between the domains.\nCheck whether the domain that the server belongs to and the domain account that you use to connect are in the same forest. This is required for SSPI to work.\nUse the Account is Trusted for Delegation option in Active Directory Users and Computers when you start SQL Server.\nNote The ‘Account is Trusted for Delegation’ right is only required when you are delegating credentials from the target SQL server to a remote SQL server such as in a double hop scenario like distributed queries (linked server queries) that use Windows authentication.\nUse the Manipulate Service Principal Names for Accounts (SetSPN.exe) utility in the Windows 2000 Resource Kit. Windows 2000 domain administrator accounts or Windows 2003 domain administrator accounts can use the utility to control the SPN that is assigned to a service and an account. In the case of SQL Server, there must be one and only one SPN. The SPN must be assigned to the appropriate container, the current SQL Server service account in most cases and the computer account when SQL Server starts with the local system account. If you start SQL Server while logged on with the LocalSystem account, the SPN is automatically set up. However, if you use a domain account to start SQL Server, or whenever you change the account that is used to start SQL Server, you must run SetSPN.exe to remove expired SPNs, and then you must add a valid SPN. For additional information, see the \u0026ldquo;Security Account Delegation\u0026rdquo; topic in SQL Server 2000 Books Online. To do so, visit the following Microsoft Web site: http://msdn2.microsoft.com/en-us/library/aa905162(SQL.80).aspx\nFor more information about Windows 2000 Resource Kits, visit the following Microsoft Web site:\nhttp://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/default.mspx?mfr=true\nVerify that name resolution is occurring correctly. Name resolution methods may include DNS, WINS, HOSTS files, and LMHOSTS files. For more information about name resolution problems and troubleshooting, click the following article number to view the article in the Microsoft Knowledge Base: 169790 How to troubleshoot basic TCP/IP problems\nFor more information about how to troubleshoot accessibility and firewall issues with Active Directory, click the following article numbers to view the articles in the Microsoft Knowledge Base: 291382 Frequently asked questions about Windows 2000 DNS and Windows Server 2003 DNS\n224196 Restricting Active Directory replication traffic and client RPC traffic to a specific port\nHow to configure the SQL Server service to create SPNs dynamically for the SQL Server instances To configure the SQL Server service to create SPNs dynamically, you must modify the account’s access control settings in the Active Directory directory service. You must grant the \u0026ldquo;Read servicePrincipalName\u0026rdquo; permission and the \u0026ldquo;Write servicePrincipalName\u0026rdquo; permission for the SQL Server service account.\nWarning If you use the Active Directory Service Interfaces (ADSI) Edit snap-in, the LDP utility, or any other LDAP version 3 clients and you incorrectly modify the attributes of Active Directory objects, you can cause serious problems. These problems may require that you reinstall Microsoft Windows Server 2003, Microsoft Windows 2000 Server, Microsoft Exchange Server 2003, Microsoft Exchange 2000 Server, or both Windows and Exchange. We cannot guarantee that problems caused by incorrectly modifying the attributes of Active Directory objects can be resolved. Modify these attributes at your own risk.\nNote To grant the appropriate permissions and user rights to the SQL Server startup account, you must be logged on as a domain administrator, or you must ask your domain administrator to do this task.\nTo configure the SQL Server service to create SPNs dynamically, follow these steps:\nClick Start, click Run, type Adsiedit.msc, and then click OK.\nIn the ADSI Edit snap-in, expand Domain [DomainName], expand DC=RootDomainName, expand CN=Users, right-click CN=AccountName, and then clickProperties.\nNotes\nDomainName is a placeholder for the name of the domain. RootDomainName is a placeholder for the name of the root domain. AccountName is a placeholder for the account that you specify to start the SQL Server service. If you specify the Local System account to start the SQL Server service, AccountNameis a placeholder for the account that you use to log on to Microsoft Windows. If you specify a domain user account to start the SQL Server service, AccountName is a placeholder for the domain user account. In the CN=AccountNameProperties dialog box, click the Security tab.\nOn the Security tab, click Advanced.\nIn the Advanced Security Settings dialog box, make sure that SELF is listed underPermission entries.\nIf SELF is not listed, click Add, and then add SELF.\nUnder Permission entries, click SELF, and then click Edit.\nIn the Permission Entry dialog box, click the Properties tab.\nOn the Properties tab, click This object only in the Apply onto list, and then make sure that the check boxes for the following permissions are selected under Permissions:\no Read servicePrincipalName\no Write servicePrincipalName\nClick OK three times, and then exit the ADSI Edit snap-in. For help with this process, contact Active Directory product support, and mention this Microsoft Knowledge Base article.\nVerify the server environment Check some basic settings on the computer where SQL Server is installed:\nKerberos is not supported on Windows 2000-based computers that are running Windows Clustering unless you have applied Service Pack 3 (or later) to Windows 2000. Therefore any attempt to use SSPI authentication on a clustered instance of SQL Server might not succeed. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 235529 Kerberos support on Windows 2000-based server clusters\nVerify that the server is running Windows 2000 Service Pack 1 (SP1). For more information about Kerberos support on Windows 2000-based servers, click the following article number to view the article in the Microsoft Knowledge Base: 267588 \u0026ldquo;Cannot generate SSPI context\u0026rdquo; error message is displayed when you connect to SQL Server 2000\nOn a cluster, if the account that you use to start SQL Server, SQL Server Agent, or full-text search services changes, such as a new password, follow the steps that are provided in the following Microsoft Knowledge Base article: 239885 How to change service accounts for a clustered computer that is running SQL Server\nVerify if the account that you use to start SQL Server has the appropriate permissions. If you are using an account that is not a member of the Local Administrators group, see the \u0026ldquo;Setting up Windows Services Accounts\u0026rdquo; topic in SQL Server Books Online for a detailed list of permissions that this account must have: http://msdn2.microsoft.com/en-us/library/aa176564(SQL.80).aspx\nVerify the client environment Verify the following on the client:\nMake sure that the NTLM Security Support Provider is correctly installed and enabled on the client. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 269541 Error message when you connect to SQL Server if the Windows NT LM Security Support Provider registry key is missing: \u0026ldquo;cannot generate SSPI context\u0026rdquo;\nDetermine if you are using cached credentials. If you are logged on to the client with cached credentials, log off the computer and then log back on when you can connect to a domain controller to prevent the cached credentials from being used. For more information about how to determine if you are using cached credentials, click the following article number to view the article in the Microsoft Knowledge Base: 242536 User is not alerted when logging on with domain cached credentials\nVerify that the dates on the client and the server are valid. If the dates are too far apart, your certificates may be considered invalid.\nSSPI uses a file named Security.dll. If any other application installs a file with this name, the other file may be used instead of the actual SSPI file. For more information, click the following article number to view the article in the Microsoft Knowledge Base:\n253577 Error: 80004005 – MS ODBC SQL Server driver cannot initialize SSPI package\nIf the operating system on the client is Microsoft Windows 98, you must install the Client for Microsoft Networks component on the client. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 267550 BUG: \u0026ldquo;Assertion failed\u0026rdquo; when you connect to a SQL Server through TCP/IP\nVerify the client network utility The Client Network Utility (CNU) is delivered together with Microsoft Data Access Components (MDAC) and it is used to configure connectivity to computers that are running SQL Server. You can use the MDAC Cliconfg.exe CNU utility to configure connectivity:\nOn the General tab, the way protocols are defined varies according to the MDAC version. With earlier versions of MDAC, you can select a \u0026ldquo;default\u0026rdquo; protocol. On the latest versions of MDAC, you can enable one or more protocols with one at the top of the list when you connect to SQL Server. Because SSPI applies only to TCP/IP, you can use a different protocol, such as Named Pipes, to avoid the error. Check the Alias tab in the CNU to verify if an alias has been defined for the server that you are trying to connect. If a server alias has been defined, check the settings for how this computer is configured to connect to SQL Server. You can verify this by deleting the alias server to see if the behavior changes. If the alias server is not defined on CNU, add the alias for the server that you are connecting to. When you perform this task, you are also explicitly defining the protocol and optionally defining the IP address and the port. Information to collect to open a Microsoft Product Support (PSS) case If you cannot obtain the cause of the problem by using the troubleshooting steps in this article, collect the following information and open a Microsoft Product Support (PSS) case:\nFor a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:\nhttp://support.microsoft.com/contactus/?ws=support\nGenerate a sqldiag report from SQL Server. For more information, see the \u0026ldquo;sqldiag Utility\u0026rdquo; topic in SQL Server Books Online.\nCapture a screenshot of the error on the client.\nOn the node that cannot connect to SQL Server, type the following command from the command prompt:\nnet start \u0026gt; started.txt\nThis command generates a file named Started.txt in the directory where you run the command.\nSave the values for the registry key under the following registry key on your client computer: HKEY_LOCAL_MACHINE\\SOFTWARE\\MICROSOFT\\MSSQLSERVER\\CLIENT\\CONNECTTO\nIn a clustered environment, get the value of following registry key for each node of the cluster: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\LSA\\LMCompatibilityLevel\nIn a clustered environment, see if the following registry key exists on each cluster server node: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\NTLMSsp\nCapture the results if you connect to SQL Server by using a Universal Naming Convention (UNC) name (or the SQL Network Name on a cluster) from the client.\nCapture the results if you ping the computer name (or the SQL Network Name on a cluster) from the client.\nSave the name of the user accounts you use to start each one of the SQL Server services (MSSQLServer, SQLServerAgent, MSSearch).\nThe support professional must know whether SQL Server is configured for Mixed Authentication or Windows Only Authentication.\nSee if you can connect to the computer that is running SQL Server from the same client by using SQL Server Authentication.\nSee if you can connect by using Named Pipes protocol.\nHow to manually set up a Service Principal Name for SQL Server For more information about how to manually set up a Service Principal Name for SQL Server, click the following article number to view the article in the Microsoft Knowledge Base:\n319723 How to use Kerberos authentication in SQL Server\nThe Security Support Provider Interface (SSPI) is the interface to Microsoft Windows NT security that is used for Kerberos authentication, and supports the authentication scheme of the NTLM Security Support Provider. Authentication occurs at the operating system level when you log on to a Windows domain. Kerberos authentication is only available on Windows 2000-based computers that have Kerberos enabled and that are using Active Directory.\nSSPI is only used for TCP/IP connections that are made by using Windows Authentication. (Windows Authentication is also known as Trusted Connections or Integrated Security.) SSPI is not used by Named Pipes or multi-protocol connections. Therefore, you can avoid the problem by configuring your clients to connect from a protocol other than TCP/IP.\nWhen a SQL Server client tries to use integrated security over TCP/IP sockets to a remote computer that is running SQL Server, the SQL Server client network library uses the SSPI API to perform security delegation. The SQL Server network client (Dbnetlib.dll) makes a call to theAcquireCredentialsHandle function and passes in \u0026ldquo;negotiate\u0026rdquo; for the pszPackage parameter. This notifies the underlying security provider to perform negotiate delegation. In this context, negotiate means to try either Kerberos or NTLM authentication on Windows-based computers. In other words, Windows use Kerberos delegation if the destination computer that is running SQL Server has an associated, correctly configured SPN. Otherwise, Windows use NTLM delegation.\nNote Verify that you are not using an account named \u0026ldquo;SYSTEM\u0026rdquo; to start any of the SQL Server services (MSSQLServer, SQLServerAgent, MSSearch). The keyword SYSTEM may cause conflicts with the Key Distribution Center (KDC).\nComments (archived from WordPress) elephant gifts south africa · 2015-10-31\nEveryone loves what you guys tend to be up too.\nSuch clever work and coverage! Keep up the superb works guys I’ve incorporated you guys to our blogroll.\nBestRaymond · 2019-07-28\nI see you don’t monetize simonsql.com, don’t waste your traffic, you can earn extra cash every month with new monetization method. This is the best adsense alternative for any type of website (they approve all sites), for more info simply search in gooogle: murgrabia’s tools\n","date":"2011-04-26T14:32:15-07:00","permalink":"/2011/04/26/how-to-troubleshoot-the-cannot-generate-sspi-context-error-message/","title":"How to troubleshoot the “Cannot generate SSPI context” error message"},{"content":"Understanding Kerberos and NTLM authentication in SQL Server Connections http://blogs.msdn.com/b/sql_protocols/archive/2006/12/02/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections.aspx\nSQL Linked Server Query failed with “Login failed for user …\u0026quot; http://blogs.msdn.com/b/sql_protocols/archive/2006/08/10/694657.aspx\n","date":"2011-04-26T13:56:00-07:00","permalink":"/2011/04/26/understanding-kerberos-and-ntlm-authentication-in-sql-server-connections/","title":"Understanding Kerberos and NTLM authentication in SQL Server Connections"},{"content":"http://support.microsoft.com/kb/909801/ How to register an SPN in a domain When you register an SPN for a SQL Server service, you essentially create a mapping between an SPN and the Windows account that started the server instance service.\nYou must register the SPN because the client must use a registered SPN to connect to the server instance. The SPN is composed by using the server’s computer name and the TCP/IP port. If you do not register the SPN, the SSPI cannot determine the account that is associated with the SPN. Therefore, Kerberos authentication will not be used.\nWhen SQL Server is running under the local system account or under a domain administrator account, the instance will automatically register the SPN in the following format when the instance starts:\nMSSQLSvc/FQDN:tcpport\nNoteFQDN is the fully qualified domain name of the server. tcpport is the TCP/IP port number.\nBecause the TCP port number is included in the SPN, SQL Server must enable the TCP/IP protocol for a user to connect by using Kerberos authentication. The same rules apply for clustered configurations. Additionally, if the instance automatically registered an SPN when the instance started, the SPN will be unregistered automatically when the instance stops.\nOnly a domain administrator account or the local system account has the required permissions to register an SPN. Therefore, if the SQL Server service is started under a non-administrator account, SQL Server cannot register the SPN for the instance. This behavior will not prevent the instance from starting. However, the following message will be logged in the Application log of the Windows event log:\nEvent Type: Information Event Source: MSSQL$InstanceName Event Category: (2) Event ID: 26037 Date: Date Time: Time User: N/A Computer: ComputerName Description: The SQL Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x54b. Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies. For more information, see Help and Support Center at http://support.microsoft.com.\nIf this message is logged, you must manually register the SPN for the instance under a domain administrator account to use Kerberos authentication. To register the SPN, you can use the SetSPN.exe tool that is included with the Microsoft Windows 2000 Server Resource Kit. This tool is also included with the Microsoft Windows Server 2003 Support Tools. The Windows Server 2003 Support Tools are included in Microsoft Windows Server 2003 Service Pack 1 (SP1).\nFor more information about how to obtain the Windows Server 2003 Service Pack 1 Support Tools, click the following article number to view the article in the Microsoft Knowledge Base:\n892777 Windows Server 2003 Service Pack 1 Support Tools\nYou can use a command that is similar to the following to register an SPN for an instance:\nSetSPN –A MSSQLSvc/.:1433 Note If an SPN already exists, you must delete the SPN before you can reregister it. You may have to do this if the account mapping has changed. To deleted an existing SPN, you can use the SetSPN.exe tool together with the -D switch.\nHow to make sure that you are using Kerberos authentication After you connected to an instance of SQL Server 2005, run the following Transact-SQL statement in SQL Server Management Studio:\n1 select auth_scheme from sys.dm_exec_connections where session_id=@@spid If SQL Server is using Kerberos authentication, a character string that is listed as \u0026ldquo;KERBEROS\u0026rdquo; appears in the auth_scheme column in the result window.\n","date":"2011-04-26T13:55:10-07:00","permalink":"/2011/04/26/how-to-make-sure-that-you-are-using-kerberos-authentication-when-you-create-a-remote-connection-to-an-instance-of-sql-server-2005/","title":"How to make sure that you are using Kerberos authentication when you create a remote connection to an instance of SQL Server 2005"},{"content":"http://support.microsoft.com/kb/262177\nEnabling Kerberos Event Logging on a Specific Computer\nStart Registry Editor.\nAdd the following registry value:\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Lsa\\Kerberos\\Parameters\nRegistry Value: LogLevel Value Type: REG_DWORD Value Data: 0x1\nIf the Parameters subkey does not exist, create it.\nNote Remove this registry value when it is no longer needed so that performance is not degraded on the computer. Also, you can remove this registry value to disable Kerberos event logging on a specific computer.\nQuit Registry Editor. The setting will become effective immediately on Windows Server 2008, on Windows Vista, on Windows Server 2003, and on Windows XP. For Windows 2000, you must restart the computer. You can find any Kerberos-related events in the system log.\n","date":"2011-04-26T13:52:42-07:00","permalink":"/2011/04/26/kerberos-error-event-logging/","title":"Kerberos error event logging"},{"content":" There are no PerfStats for SQL 2008 R2. for that you need to modified XML file.\nto\nSQL Server 2008R2 =10.5\nSQL Server 2008 =10\nSQL Server 2005 =9\nx64 issue for RML Try these steps:\ngo to add/remove programs and uninstall old RML program then download latest http://www.microsoft.com/downloads/details.aspx?familyid=7EDFA95A-A32F-440F-A3A8-5160C8DBE926\u0026displaylang=en and install it. this should over-write the registry key to use the latest. If you had installed http://www.microsoft.com/downloads/details.aspx?familyid=7EDFA95A-A32F-440F-A3A8-5160C8DBE926\u0026displaylang=en, go to C:\\Program Files\\Microsoft Corporation\\RMLUtils and do orca.exe /R from there. note that this assumes you are using 32 bit. if you are on x64, you need to download 64 bit readtrace ","date":"2011-04-12T18:38:05-07:00","permalink":"/2011/04/12/sql-nexus-for-sql-2008-r2-x64/","title":"SQL Nexus for SQL 2008 R2 x64"},{"content":" lag Trace Flag Description (underlined are sp_configure’able) -1 Sets trace flags for all connections. Used only with DBCC TRACEON and TRACEOFF. The setting of the Trace flag -1 is not visible with DBCC TRACESTATUS command, but work without problems. 105 SQL Server 6.5 you can use maximum 16 tables or subqueries in a single select statement. There is no documented way, to avoid this restriction, but you can use undocumented trace flag 105 for this purpose. 106 Disables line number information for syntax errors. 107 Interprets numbers with a decimal point as float instead of decimal. 110 Turns off ANSI select characteristics. 204 A backward compatibility switch that enables non-ansi standard behavior. E.g. previously SQL server ignored trailing blanks in the like statement and allowed queries that contained aggregated functions to have items in the group by clause that were not in the select list. 205 Report when a statistics-dependent stored procedure is being recompiled as a result of AutoStat. 206 Provides backward compatibility for the setuser statement. 208 SET QUOTED IDENTIFIER ON. 237 Tells SQL Server to use correlated sub-queries in Non-ANSI standard backward compatibility mode. 242 Provides backward compatibility for correlated subqueries where non-ANSI-standard results are desired. 243 The behavior of SQL Server is now more consistent because null ability checks are made at run time and a null ability violation results in the command terminating and the batch or transaction process continuing. 244 Disables checking for allowed interim constraint violations. By default, SQL Server checks for and allows interim constraint violations. An interim constraint violation is caused by a change that removes the violation such that the constraint is met, all within a single statement and transaction. SQL Server checks for interim constraint violations for self-referencing DELETE statements, INSERT, and multi-row UPDATE statements. This checking requires more work tables. With this trace flag you can disallow interim constraint violations, thus requiring fewer work tables. 246 Derived or NULL columns must be explicitly named in a select….INTO or create view statement when not done they raise an error. This flag avoids that. 253 Prevents ad-hoc query plans to stay in cache. 257 Will invoke a print algorithm on the XML output before returning it to make the XML result more readable. 260 Prints versioning information about extended stored procedure dynamic-link libraries (DLLs). For more information about __GetXpVersion(), see Creating Extended Stored Procedures. Scope: global or session 262 SQL 7 – Trailing spaces are no longer truncated from literal strings in CASE statements. Used after hotfix 891116 302 Should be used with flag 310 to show the actual join ordering. Prints information about whether the statistics page is used, the actual selectivity (if available), and what SQL Server estimated the physical and logical I/O would be for the indexes. 310 Prints information about join order. Index selection information is also available in a more readable format using SET SHOWPLAN_ALL, as described in the SET statement. 320 Disables join-order heuristics used in ANSI joins. To see join-order heuristics use flag 310. SQL Server uses join-order heuristics to reduce the no’ of permutations when using the best join order. 323 Reports on the use of update statements using UPDATE in place. Shows a detailed description of the various update methods used by SQL Server 6.5. 325 Prints information about the cost of using a non-clustered index or a sort to process an ORDER BY clause. 326 Prints information about the estimated \u0026amp; actual costs of sorts. Instructs the server to use arithmetic averaging when calculating density instead of a geometric weighted average when updating statistics. Useful for building better stats when an index has skew on the leading column. Use only for updating the stats of a table/index with known skewed data. 330 Enables full output when using the SET SHOWPLAN_ALL option, which gives detailed information about joins. 342 Disables the costing of pseudo-merge joins, thus significantly reducing time spent on the parse for certain types of large, multi-table joins. One can also use SET FORCEPLAN ON to disable the costing of pseudo-merge joins because the query is forced to use the order specified in the FROM clause. 345 Increase the accuracy of choice of optimum order when you join 6 or more tables. 506 Enforces SQL-92 standards regarding null values for comparisons between variables and parameters. Any comparison of variables and parameters that contain a NULL always results in a NULL. 610 SQL 10 – Enable the potential for minimal-logging when: · Bulk loading into an empty clustered index, with no nonclustered indexes · Bulk loading into a non-empty heap, with no nonclustered indexes 611 After SQL 9 when turned on, each lock escalation is recorded in the SQL Server error log along with the SQL Server handle number. 652 Disables read ahead for the server. 653 Disables read ahead for the current connection. 661 Disables the ghost record removal process. A ghost record is the result of a delete operation. When you delete a record, the deleted record is kept as a ghost record. Later, the deleted record is purged by the ghost record removal process. When you disable this process, the deleted record is not purged. Therefore, the space that the deleted record consumes is not freed. This behavior affects space consumption and the performance of scan operations. SCOPE: Global. If you turn off this trace flag, the ghost record removal process works correctly. 806 Cause ‘DBCC-style’ page auditing to be performed whenever a database page is read into the buffer pool. This is useful to catch cases where pages are being corrupted in memory and then written out to disk with a new page checksum. When they’re read back in the checksum will look correct, but the page is corrupt (because of the previous memory corruption). This page auditing goes someway to catching this – especially on non-Enterprise Edition systems that don’t have the ‘checksum sniffer’. 809 SQL 8 – Limits the amount of Lazy Write activity. 815 Enables latch enforcement. SQL Server 8 (with service pack 4) and SQL Server 9 can perform latch enforcement for data pages found in the buffer pool cache. Latch enforcement changes the virtual memory protection state while database page status changes from “clean” to “dirty” (“dirty” means modified through INSERT, UPDATE or DELETE operation). If an attempt is made to modify a data page while latch enforcement is set, it causes an exception and creates a mini-dump in SQL Server installation’s LOG directory. Microsoft support can examine the contents of such mini-dump to determine the cause of the exception. In order to modify the data page the connection must first acquire a modification latch. Once the data modification latch is acquired the page protection is changed to read-write. Once the modification latch is released the page protection changes back to read-only. 818 SQL 8 enables in memory ring buffer used to track last 2048 successful write operations. 830 SQL 9 – disable the reporting of CPU Drift errors in the SQL Server errorlog like SQL Server has encountered 2 occurrence(s) of I/O requests taking longer than 15 seconds to complete 834 Causes SQL Server to use Windows large-page allocations for the memory that is allocated for the buffer pool. The page size varies depending on the hardware platform, but the page size may be from 2 MB to 16 MB. Large pages are allocated at startup and are kept throughout the lifetime of the process. Trace flag 834 improves performance by increasing the efficiency of the translation look-aside buffer (TLB) in the CPU. Flag 834 applies only to 64-bit versions of SQL Server. You must have the Lock pages in memory user right to turn on trace flag 834. You can turn on trace flag 834 only at startup. Trace flag 834 may prevent the server from starting if memory is fragmented and if large pages cannot be allocated. Therefore, trace flag 834 is best suited for servers that are dedicated to SQL Server. For more information about large-page support, http://msdn2.microsoft.com/en-us/library/aa366720.aspx(http://msdn2.microsoft.com/en-us/library/aa366720.aspx) 835 SQL 9 \u0026amp; 10. For 64 bit SQL Server. This turns off Lock pages in memory. 836 Causes SQL Server to size the buffer pool at startup based on the value of the max server memory option instead of based on the total physical memory. You can use trace flag 836 to reduce the number of buffer descriptors that are allocated at startup in 32-bit Address Windowing Extensions (AWE) mode. Trace flag 836 applies only to 32-bit versions of SQL Server that have the AWE allocation enabled. You can turn on trace flag 836 only at startup. 845 SQL 9 \u0026amp; 10. For 64 bit SQL Server. This turns on Lock pages in memory. 1117 Grows all data files at once, else it goes in turns. 1118 Switches allocations in tempDB from 1pg at a time (for first 8 pages) to one extent. There is now a cache of temp tables. When a new temp table is created on a cold system it uses the same mechanism as for SQL 8. When it is dropped though, instead of all the pages being deallocated completely, one IAM page \u0026amp; one data page are left allocated, then the temp table is put into a special cache. Subsequent temp table creations will look in the cache to see if they can just grab a pre-created temp table. If so, this avoids accessing the allocation bitmaps completely. The temp table cache isn’t huge (32 tables), but this can still lead to a big drop in latch contention in tempdb. http://www.sqlskills.com/BLOGS/PAUL/post/Misconceptions-around-TF-1118.aspx 1180 Forces allocation to use free pages for text or image data and maintain efficiency of storage. 1197 applies only in the case of SQL 7 – SP3. Helpful in case when DBCC SHRINKFILE and SHRINKDATABASE commands may not work because of sparsely populated text, ntext, or image columns 1197 1200 Prints lock information (the process ID and type of lock requested). 1202 Insert blocked lock requests into syslocks. 1204 Returns resources and types of locks participating in a deadlock and command affected. Scope: global only 1205 More detailed information about the command being executed at the time of a deadlock. This trace flag was documented in SQL Server 7.0 Books Online, but was not documented in SQL Server 8. 1206 Used to complement flag 1204 by displaying other locks held by deadlock parties 1211 Disables lock escalation based on memory pressure, or based on number of locks. The SQL Server Database Engine will not escalate row or page locks to table locks. Using this trace flag can generate excessive numbers of locks. This can slow the performance of the Database Engine, or cause 1204 errors (unable to allocate lock resource) because of insufficient memory. For more information, see Lock Escalation (Database Engine). If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. This helps avoid “out-of-locks” errors when many locks are being used. Scope: global or session 1216 SQL 7 – Disables Health reporting. Lock monitor when detects a (worker thread) resource level blocking scenario. If a SPID that owns a lock is currently queued to the scheduler, because all the assigned worker threads have been created and all the assigned worker threads are in an un-resolvable wait state, the following error message is written to the SQL Server error log: Error 1223: Process ID %d:%d cannot acquire lock “%s” on resource %s because a potential deadlock exists on Scheduler %d for the resource. Process ID %d:% d holds a lock “%h” on this resource. 1222 Returns the resources and types of locks that are participating in a deadlock and also the current command affected, in an XML format that does not comply with any XSD schema. Scope: global only 1224 Disables lock escalation based on the number of locks. However, memory pressure can still activate lock escalation. The Database Engine escalates row or page locks to table (or partition) locks if the amount of memory used by lock objects exceeds one of the following conditions: · 40% of the memory that is used by Db Engine, exclusive of memory allocation using Address Windowing Extension (AWE). This is applicable when the locks parameter of sp_configure is set to 0. · Forty percent of the lock memory that is configured by using the locks parameter of sp_configure. If both trace flag 1211 and 1224 are set, 1211 takes precedence over 1224. However, because trace flag 1211 prevents escalation in every case, even under memory pressure, we recommend that you use 1224. This helps avoid “out-of-locks” errors when many locks are being used. Note:Lock escalation to the table- or HoBT-level granularity can also be controlled by using the LOCK_ESCALATION option of the ALTER TABLE statement. Scope:global or session 1261 SQL 8 – Disables Health reporting. Lock monitor when detects a (worker thread) resource level blocking scenario. If a SPID that owns a lock is currently queued to the scheduler, because all the assigned worker threads have been created and all the assigned worker threads are in an un-resolvable wait state, the following error message is written to the SQL Server error log: Error 1229: Process ID %d:%d owns resources that are blocking processes on scheduler %d. 1400 Enables the creation of the database mirroring endpoint, which is required for setting up and using database mirroring. This trace flag is allowed only when using the –T. 1462 Turns off log stream compression and effectively reverts the behavior back to ver 9. 1603 Use standard disk I/O (i.e. turn off asynchronous I/O). 1609 Turns on the unpacking and checking of remote procedure call (RPC) information in Open Data Services. Used only when applications depend on the old behavior. 1610 Boot the SQL dataserver with TCP_NODELAY enabled. 1611 If possible, pin shared memory — check errorlog for success/failure. 1704 Prints information when a temporary table is created or dropped. 1717 Causes new objects being created to be system objects. 1806 Disables instant file initialization. 1807 Allows creating a database file on a mapped or UNC network location. unsupported under SQL Server 7 \u0026amp; 8. 2301 Enables advanced optimizations that are specific to decision support queries. This option applies to decision support processing of large data sets. 2330 Stops the collection of statistics for sys.db_index_usage_stats. 2382 Statistics collected for system tables. 2389 SQL 9 – Tracks the nature of columns by subsequent statistics updates. When SQL Server determines that the statistics increase three times, the column is branded ascending. The statistics will be updated automatically at query compile. 2390 Does the same like 2389 even if ascending nature of the column is not known and — never enable without 2389. 2440 Parallel query execution strategy on partitioned tables. SQL 9 – uses a single thread per partition parallel query execution strategy. In ver. 10, multiple threads can be allocated to a single partition, thus improving the query’s response time. 2505 Prevents DBCC TRACEON 208, SPID 10 errors from appearing in the error log. 2508 Disables parallel non-clustered index checking for DBCC CHECKTABLE. 2509 Used with DBCC CHECKTABLE.html to see the total count of ghost records in a table 2520 Force DBCC HELP to return syntax of undocumented DBCC statements. If 2520 is not turned on, DBCC HELP will refuse to give you the syntax stating: “No help available for DBCC statement ‘undocumented statement\u0026rsquo;”. 2528 Disables parallel checking of objects by DBCC CHECKDB, CHECKFILEGROUP and CHECKTABLE. By default, the degree of parallelism is automatically determined by the query processor. The maximum degree of parallelism is configured just like that of parallel queries. For more information, see max degree of parallelism Option. Parallel DBCC should typically be left enabled. For DBCC CHECKDB, the query processor reevaluates and automatically adjusts parallelism with each table or batch of tables checked. Sometimes, checking may start when the server is almost idle. An administrator who knows that the load will increase before checking is complete may want to manually decrease or disable parallelism. Disabling parallel checking of DBCC can cause it to take much longer to complete and if DBCC is run with the TABLOCK feature enabled and parallelism set off, tables may be locked for longer periods of time. Scope: global or session 2537 SQL 9 \u0026amp; 10. Allows function ::fn_dblog to look inside all logs (not just the active log). 2542 SQL 8 – Used with Sqldumper.exe to get certain dumps. In range 254x – 255x. 2551 Adds additional information to the dump file. 2701 Sets the @@ERROR system function to 50000 for RAISERROR messages with severity levels of 10 or less. When disabled, sets the @@ERROR system function to 0 for RAISERROR messages with severity levels of 10 or less. 2861 Cache query plans for queries that have a cost of zero or near to zero. 3001 Stops sending backup entries into MSDB. 3004 Gives out more detailed information about restore \u0026amp; backup activities. 3031 SQL 9 – will turn the NO_LOG and TRUNCATE_ONLY options into checkpoints in all recovery modes. 3104 Causes SQL Server to bypass checking for free space. 3111 Cause LogMgr::ValidateBackedupBlock to be skipped during backup and restore operations. 3205 If a tape drive supports hardware compression, either the DUMP or BACKUP statement uses it. With this trace flag, you can disable hardware compression for tape drivers. This is useful when you want to exchange tapes with other sites or tape drives that do not support compression. Scope: global or session 3213 Trace SQL Server activity during backup process so that we will come to know which part of backup process is taking more time. 3222 Disables the read ahead that is used by the recovery operation during roll forward operations. 3226 With this trace flag, you can suppress BACKUP COMPLETED log entries going to WIN and SQL logs. 3231 SQL 8 \u0026amp; 9 – will turn the NO_LOG and TRUNCATE_ONLY options into no-ops in FULL/BULK_LOGGED recovery mode, and will clear the log in SIMPLE recovery mode. 3282 SQL 6.5 – Used after backup restoration fails refer to microsoft for article Q215458. 3422 Cause auditing of transaction log records as they’re read (during transaction rollback or log recovery). This is useful because there is no equivalent to page checksums for transaction log records and so no way to detect whether log records are being corrupted e careful with these trace flags – I don’t recommend using them unless you are experiencing corruptions that you can’t diagnose. Turning them on will cause a big CPU hit because of the extra auditing that’s happening. 3502 Tracks CHECKPOINT – Prints a message to the log at the start and end of each checkpoint. 3503 Indicates whether the checkpoint at the end of automatic recovery was skipped for a database (this applies only to read-only databases). 3504 For internal testing. Will raise a bogus log-out-of-space condition from checkpoint() 3505 Disables automatic checkpoints. May increase recovery time and can prevent log space reuse until the next checkpoint is issued. Make sure to issue manual checkpoints on all read/write databases at appropriate time intervals. Note does not prevent the internal checkpoints that are issued by certain commands, such as BACKUP. 3601 Stack trace when error raised. Also see 3603 3602 Records all error and warning messages sent to the client. 3603 SQL Server fails to install on tricore, Bypass SMT check is enabled, flags are added via registry. Also see 3601. 3604 Sends trace output to the client. This trace flag is used only when setting trace flags with DBCC TRACEON and DBCC TRACEOFF. 3605 Sends trace output to the error log. (if SQL Server is started from CMD output also appears on the screen) 3607 Trace flag 3607 skips the recovery of databases on the startup of SQL Server and clears the TempDB. Setting this flag lets you get past certain crashes, but there is a chance that some data will be lost 3608 Prevents SQL Server from automatically starting and recovering any database except the master database. Databases will be started and recovered when accessed. Some features, such as snapshot isolation and read committed snapshot, might not work. 3609 Skips the creation of the tempdb database at startup. Use this trace flag if the device or devices on which tempdb resides are problematic or problems exist in the model database. 3610 SQL 9. Divide by zero to result in NULL instead of error. 3625 Limits the amount of information returned in error messages. For more information, see Metadata Visibility Configuration. Scope: global only 3626 Turns on tracking of the CPU data for the sysprocesses table. 3640 Eliminates the sending of DONE_IN_PROC messages to the client for each statement in a stored procedure. This is similar to the session setting of SET NOCOUNT ON, but when set as a trace flag, every client session is handled this way. 3689 Logs extended errors to errorlog when network disconnect occurs, turned off by default. Will dump out the socket error code this can sometimes give you a clue as to the root cause. 3913 SQL 7/8 – SQL Server does not update the rowcnt column of the sysindexes system table until the transaction is committed. When turned on the optimizer gets row count information from in-memory metadata that is saved to sysindexes system table when the transaction commits. 4013 This trace flag writes an entry to the SQL Server error log when a new connection is established. For each connection that occurs, the trace flag writes two entries that look like this: Login: sa saSQL Query Analyzer(local)ODBCmaster, server process ID (SPID): 57, kernel process ID (KPID): 57. Login: sa XANADUsaSQL Query Analyzer(local)ODBCmaster, server process ID (SPID): 57, kernel process ID (KPID): 57. 4022 If turns on, then automatically started procedures will be bypassed. 4029 Logs extended errors to errorlog when network disconnect occurs, turned off by default. Will dump out the socket error code this can sometimes give you a clue as to the root cause. 4030 Prints both a byte and ASCII representation of the receive buffer. Used when you want to see what queries a client is sending to SQL Server. You can use this trace flag if you experience a protection violation and want to determine which statement caused it. Typically, you can set this flag globally or use SQL Server Enterprise Manager. You can also use DBCC INPUTBUFFER. 4031 Prints both a byte and ASCII representation of the send buffers (what SQL Server sends back to the client). You can also use DBCC OUTPUTBUFFER. 4032 Traces the SQL commands coming in from the client. The output destination of the trace flag is controlled with the 3605/3604 trace flags. 4101 SQL 9 – Query that involves an outer join operation runs very slowly. However, if you use the FORCE ORDER query hint in the query, the query runs much faster. Additionally, the execution plan of the query contains the following text in theWarnings column: NO JOIN PREDICATE 4121 Turn these trace flags after HOTFIX is applied (SP2 CUP4) 4606 Over comes SA password by startup. Refer to Ms article 936892. 4612 Disable the ring buffer logging – no new entries will be made into the ring buffer. 4613 Generate a minidump file whenever an entry is logged into the ring buffer. 4616 Makes server-level metadata visible to application roles. In SQL Server, an application role cannot access metadata outside its own database because application roles are not associated with a server-level principal. This is a change of behavior from earlier versions of SQL Server. Setting this global flag disables the new restrictions, and allows for application roles to access server-level metadata. Scope: global only 5302 Alters default behavior of select…INTO (and other processes) that lock system tables for the duration of the transaction. This trace flag disables such locking during an implicit transaction. 6527 Disables generation of a memory dump on the first occurrence of an out-of-memory exception in CLR integration. By default, SQL Server generates a small memory dump on the first occurrence of an out-of-memory exception in the CLR. The behavior of the trace flag is as follows: · If this is used as a startup trace flag, a memory dump is never generated. However, a memory dump may be generated if other trace flags are used. · If this trace flag is enabled on a running server, a memory dump will not be automatically generated from that point on. However, if a memory dump has already been generated due to an out-of-memory exception in the CLR, this trace flag will have no effect. Scope: global only 7103 Disable table lock promotion for text columns. Refer to Ms article – 230044 7300 Retrieves extended information about any error you encounter when you execute a distributed query. 7501 Dynamic cursors are used by default on forward-only cursors. Dynamic cursors are faster than in earlier versions and no longer require unique indexes. This flag disables the dynamic cursor enhancements and reverts to version 6.0 behavior. 7502 Disables the caching of cursor plans for extended stored procedures. 7505 Enables version 6.x handling of return codes when calling dbcursorfetchex and the resulting cursor position follows the end of the cursor result set. 7525 Reverts to the SQL Server 7 behavior of closing nonstatic cursors regardless of the SET CURSOR_CLOSE_ON_COMMIT state in SQL Server 8. 7601 Turns on full text indexing. Together these four gather more information about full text search (indexing process) to the error log. 7646 SQL 10. Avoids blocking when using full text indexing. An issue we experienced that full text can be slow when there is a high number of updates to the index and is caused by blocking on the docidfilter internal table. 7806 Enables a dedicated administrator connection (DAC) on SQL Svr Express. By default, no DAC resources are reserved on SQL Server Express. 8004 SQL server to create a mini dump once you enable 2551 and a out of memory condition is hit. 8011 Disables the collection of additional diagnostic information for Resource Monitor. You can use the information in this ring buffer to diagnose out-of-memory conditions. Scope: GLOBAL. 8012 Records an event in the schedule ring buffer every time that one of the following events occurs: · A scheduler switches context to another worker. · A worker is suspended or resumed. · A worker enters the preemptive mode or the non-preemptive mode. You can use the diagnostic information in this ring buffer to analyze scheduling problems. For example, you can use the information in this ring buffer to troubleshoot problems when SQL Server stops responding. Trace flag 8012 disables recording of event ","date":"2011-04-12T18:34:27-07:00","permalink":"/2011/04/12/sql-server-trace-flags/","title":"SQL Server Trace Flags"},{"content":"http://www.sqlservercentral.com/Forums/Topic912647-2621-1.aspx\nDECLARE @Server AS VARCHAR(128)\nDECLARE @KeyToInterogate AS VARCHAR(200)\nDECLARE @PortNumber AS VARCHAR(8)\nSET @Server = @@SERVERNAME\nSET @KeyToInterogate = ‘SOFTWARE\\MICROSOFT\\MSSQLSERVER\\MSSQLSERVER\\SUPERSOCKETNETLIB\\TCP’\nIF Charindex(‘\\’,@@SERVERNAME) \u0026gt; 0\nBEGIN\nSET @KeyToInterogate = ‘SOFTWARE\\Microsoft\\Microsoft SQL Server\\’\nSET @KeyToInterogate = @KeyToInterogate + Substring(@@SERVERNAME,Charindex(‘\\’,@@SERVERNAME) + 1,Len(@@SERVERNAME) – Charindex(‘\\’,@@SERVERNAME))\nSET @KeyToInterogate = @KeyToInterogate + ‘\\MSSQLServer\\SuperSocketNetLib\\Tcp’\nEND\nEXEC Xp_regread\n@rootkey = ‘HKEY_LOCAL_MACHINE’,\n@key = @KeyToInterogate,\n@value_name = ‘TcpPort’,\n@value = @PortNumber OUTPUT\nSELECT @@SERVERNAME AS hostname\n, Serverproperty(‘Edition’) AS edition\n, Isnull(Serverproperty(‘InstanceName’),”) AS instancename\n, Serverproperty(‘MachineName’) AS machinename\n, Serverproperty(‘ProductVersion’) AS productversion\n, CASE\nWHEN CONVERT(VARCHAR(255),Serverproperty(‘ProductVersion’)) LIKE ‘8.0%’ THEN ‘2000’\nWHEN CONVERT(VARCHAR(255),Serverproperty(‘ProductVersion’)) LIKE ‘9.0%’ THEN ‘2005’\nWHEN CONVERT(VARCHAR(255),Serverproperty(‘ProductVersion’)) LIKE ‘10.0%’ THEN ‘2008’\nWHEN CONVERT(VARCHAR(255),Serverproperty(‘ProductVersion’)) LIKE ‘10.5%’ THEN ‘2008 R2’\nEND\n, CAST(@PortNumber AS VARCHAR) AS portno\nSimon Cho ","date":"2011-04-11T18:02:06-07:00","permalink":"/2011/04/11/get-sql-server-version-port/","title":"Get SQL server version + port #"},{"content":"\nhttp://support.microsoft.com/kb/2315727/\nor\nTraverse to the C:Program FilesMicrosoft SQL Server100DTSbinn directory and run the following from the command:\nREGSVR32.EXE dts.dll\n","date":"2011-04-08T14:52:06-07:00","permalink":"/2011/04/08/article-bug-fixed-when-you-editing-sql-agent-job/","title":"article bug fixed when you editing SQL Agent Job"},{"content":"The new feature of Data collection has performance issue.\nThere is one job name as “mdw_purge_data_[db_datacollector]”\nBasically, this procedure has 2 missing indexes.\nAnd this job is for deleted orphaned records, so, it working with table scan for base table.\nSo, you should keep the small base table data.\nThat meaning is that setup the retention days as small as you can.!!\nreference : http://www.toddbaker.org/blog/2010/12/17/sql-2008-mdw-fixing-long-running-purges/\nsp: exec core.sp_purge_data\nUSE [db_datacollector]\nGO\n/****** Object: StoredProcedure [core].[sp_purge_data] Script Date: 04/06/2011 04:25:41 ******/\nSET ansi_nulls ON\nGO\nSET quoted_identifier ON\nGO\nALTER PROCEDURE [core].[Sp_purge_data] @retention_days SMALLINT = NULL,\n@instance_name SYSNAME = NULL,\n@collection_set_uid UNIQUEIDENTIFIER =\nNULL,\n@duration SMALLINT = NULL\nAS\nBEGIN\n— Security check (role membership)\nIF ( NOT ( Isnull(Is_member(N’mdw_admin’), 0) = 1 )\nAND NOT ( Isnull(Is_srvrolemember(N’sysadmin’), 0) = 1 ) )\nBEGIN\nRAISERROR(14677,\n16,\n–1,\n‘mdw_admin’)\nRETURN( 1 ) — Failure\nEND\n— Validate parameters\nIF ( ( @retention_days IS NOT NULL )\nAND ( @retention_days \u0026lt; 0 ) )\nBEGIN\nRAISERROR(14200,\n–1,\n–1,\n‘@retention_days’)\nRETURN( 1 ) — Failure\nEND\nIF ( ( @duration IS NOT NULL )\nAND ( @duration \u0026lt; 0 ) )\nBEGIN\nRAISERROR(14200,\n–1,\n–1,\n‘@duration’)\nRETURN( 1 ) — Failure\nEND\n— This table will contain a record if somebody requests purge to stop\n— If user requested us to purge data – we reset the content of it – and proceed with purge\n— If somebody in a different session wants purge operations to stop he adds a record\n— that we will discover while purge in progress\n—\n— We dont clear this flag when we exit since multiple purge operations with differnet\n— filters may proceed, and we want all of them to stop.\nDELETE FROM [core].[purge_info_internal]\nSET @instance_name = Nullif(Ltrim(Rtrim(@instance_name)), N”)\n— Calculate the time when the operation should stop (NULL otherwise)\nDECLARE @end_time DATETIME\nIF ( @duration IS NOT NULL )\nBEGIN\nSET @end_time = Dateadd(MINUTE, @duration, Getutcdate())\nEND\n— Declare table that will be used to find what are the valid\n— candidate snapshots that could be selected for purge\nDECLARE @purge_candidates TABLE (\nsnapshot_id INT NOT NULL,\nsnapshot_time DATETIME NOT NULL,\ninstance_name SYSNAME NOT NULL,\ncollection_set_uid UNIQUEIDENTIFIER NOT NULL )\n— Find candidates that match the retention_days criteria (if specified)\nIF ( @retention_days IS NULL )\nBEGIN\n— User did not specified a value for @retention_days, therfore we\n— will use the default expiration day as marked in the source info\nINSERT INTO @purge_candidates\nSELECT s.snapshot_id,\ns.snapshot_time,\ns.instance_name,\ns.collection_set_uid\nFROM core.snapshots s\nWHERE ( Getutcdate() \u0026gt;= s.valid_through )\nEND\nELSE\nBEGIN\n— User specified a value for @retention_days, we will use this overriden value\n— when deciding what means old enough to qualify for purge this overrides\n— the days_until_expiration value specified in the source_info_internal table\nINSERT INTO @purge_candidates\nSELECT s.snapshot_id,\ns.snapshot_time,\ns.instance_name,\ns.collection_set_uid\nFROM core.snapshots s\nWHERE Getutcdate() \u0026gt;= Dateadd(DAY, @retention_days,\ns.snapshot_time)\nEND\n— Determine which is the oldest snapshot, from the list of candidates\nDECLARE oldest_snapshot_cursor CURSOR FORWARD_ONLY READ_ONLY FOR\nSELECT p.snapshot_id,\np.instance_name,\np.collection_set_uid\nFROM @purge_candidates p\nWHERE ( ( @instance_name IS NULL )\nOR ( p.instance_name = @instance_name ) )\nAND ( ( @collection_set_uid IS NULL )\nOR ( p.collection_set_uid = @collection_set_uid ) )\nORDER BY p.snapshot_time ASC\nOPEN oldest_snapshot_cursor\nDECLARE @stop_purge INT\nDECLARE @oldest_snapshot_id INT\nDECLARE @oldest_instance_name SYSNAME\nDECLARE @oldest_collection_set_uid UNIQUEIDENTIFIER\nFETCH NEXT FROM oldest_snapshot_cursor INTO @oldest_snapshot_id,\n@oldest_instance_name, @oldest_collection_set_uid\n— As long as there are snapshots that matched the time criteria\nWHILE @@FETCH_STATUS = 0\nBEGIN\n— Filter out records that do not match the other filter crieria\nIF ( ( @instance_name IS NULL )\nOR ( @oldest_instance_name = @instance_name ) )\nBEGIN\n— There was no filter specified for instance_name or the instance matches the filter\nIF ( ( @collection_set_uid IS NULL )\nOR ( @oldest_collection_set_uid = @collection_set_uid )\n)\nBEGIN\n— There was no filter specified for the collection_set_uid or the collection_set_uid matches the filter\nBEGIN TRANSACTION tran_sp_purge_data\n— Purge data associated with this snapshot. Note: deleting this snapshot\n— triggers cascade delete in all warehouse tables based on the foreign key\n— relationship to snapshots table\n— Cascade cleanup of all data related referencing oldest snapshot\nDELETE core.snapshots_internal\nFROM core.snapshots_internal s\nWHERE s.snapshot_id = @oldest_snapshot_id\nCOMMIT TRANSACTION tran_sp_purge_data\nPRINT ‘Snapshot #’ + CONVERT(NVARCHAR(MAX),\n@oldest_snapshot_id)\n‘ purged.’;\nEND\nEND\n— Check if the execution of the stored proc exceeded the @duration specified\nIF ( @duration IS NOT NULL )\nBEGIN\nIF ( Getutcdate() \u0026gt;= @end_time )\nBEGIN\nPRINT ‘Stopping purge. More than ‘ +\nCONVERT(NVARCHAR(MAX), @duration)\n‘ minutes passed since the start of operation.’;\nBREAK\nEND\nEND\n— Check if somebody wanted to stop the purge operation\nSELECT @stop_purge = COUNT(stop_purge)\nFROM [core].[purge_info_internal]\nIF ( @stop_purge \u0026gt; 0 )\nBEGIN\nPRINT ‘Stopping purge. Detected a user request to stop purge.’\n;\nBREAK\nEND\n— Move to next oldest snapshot\nFETCH NEXT FROM oldest_snapshot_cursor INTO @oldest_snapshot_id,\n@oldest_instance_name, @oldest_collection_set_uid\nEND\nCLOSE oldest_snapshot_cursor\nDEALLOCATE oldest_snapshot_cursor\n— Delete orphaned rows from snapshots.notable_query_plan. Query plans are not deleted by the generic purge\n— process that deletes other data (above) because query plan rows are not tied to a particular snapshot ID.\n— Purging query plans table and the smaller query text table as a special case, by looking for plans that\n— are no longer referenced by any of the rows in the snapshots.query_stats table. We need to delete these\n— rows in small chunks, since deleting many GB in a single delete statement would cause lock escalation and\n— an explosion in the size of the transaction log (individual query plans can be 10-50MB).\nDECLARE @delete_batch_size BIGINT;\nDECLARE @rows_affected INT;\nSET @delete_batch_size = 500;\nSET @rows_affected = 500;\nWHILE ( @rows_affected = @delete_batch_size )\nBEGIN\nDELETE TOP (@delete_batch_size) snapshots.notable_query_plan\nFROM snapshots.notable_query_plan AS qp\nWHERE NOT EXISTS (SELECT snapshot_id\nFROM snapshots.query_stats AS qs\nWHERE qs.[sql_handle] = qp.[sql_handle]\nAND qs.plan_handle = qp.plan_handle\nAND qs.plan_generation_num =\nqp.plan_generation_num\nAND qs.statement_start_offset =\nqp.statement_start_offset\nAND qs.statement_end_offset =\nqp.statement_end_offset\nAND qs.creation_time = qp.creation_time);\nSET @rows_affected = @@ROWCOUNT;\nIF( @rows_affected \u0026gt; 0 )\nBEGIN\nRAISERROR (\n‘Deleted %d orphaned rows from snapshots.notable_query_plan’,\n0,\n1,\n@rows_affected) WITH NOWAIT;\nEND\n— Check if the execution of the stored proc exceeded the @duration specified\nIF ( @duration IS NOT NULL )\nBEGIN\nIF ( Getutcdate() \u0026gt;= @end_time )\nBEGIN\nPRINT ‘Stopping purge. More than ‘ +\nCONVERT(NVARCHAR(MAX), @duration)\n‘ minutes passed since the start of operation.’;\nBREAK\nEND\nEND\n— Check if somebody wanted to stop the purge operation\nSELECT @stop_purge = COUNT(stop_purge)\nFROM [core].[purge_info_internal]\nIF ( @stop_purge \u0026gt; 0 )\nBEGIN\nPRINT ‘Stopping purge. Detected a user request to stop purge.’\n;\nBREAK\nEND\nEND;\n— Do the same purge process for query text rows in the snapshots.notable_query_text table.\nSET @rows_affected = 500;\nWHILE ( @rows_affected = @delete_batch_size )\nBEGIN\nDELETE TOP (@delete_batch_size) snapshots.notable_query_text\nFROM snapshots.notable_query_text AS qt\nWHERE NOT EXISTS (SELECT snapshot_id\nFROM snapshots.query_stats AS qs\nWHERE qs.[sql_handle] = qt.[sql_handle]);\nSET @rows_affected = @@ROWCOUNT;\nIF( @rows_affected \u0026gt; 0 )\nBEGIN\nRAISERROR (\n‘Deleted %d orphaned rows from snapshots.notable_query_text’,\n0,\n1,\n@rows_affected) WITH NOWAIT;\nEND\n— Check if the execution of the stored proc exceeded the @duration specified\nIF ( @duration IS NOT NULL )\nBEGIN\nIF ( Getutcdate() \u0026gt;= @end_time )\nBEGIN\nPRINT ‘Stopping purge. More than ‘ +\nCONVERT(NVARCHAR(MAX), @duration)\n‘ minutes passed since the start of operation.’;\nBREAK\nEND\nEND\n— Check if somebody wanted to stop the purge operation\nSELECT @stop_purge = COUNT(stop_purge)\nFROM [core].[purge_info_internal]\nIF ( @stop_purge \u0026gt; 0 )\nBEGIN\nPRINT ‘Stopping purge. Detected a user request to stop purge.’\n;\nBREAK\nEND\nEND;\nEND\n","date":"2011-04-06T04:30:23-07:00","permalink":"/2011/04/06/performance-issue-with-data-collection/","title":"Performance issue with Data collection"},{"content":"Hi all,\nHave you ever need a concatenation string function for group by clause?\nHere is the solution.\nhttp://www.projectdmx.com/tsql/rowconcatenate.aspx\nAnd I like this process.\nEx)\nset nocount on;\nif OBJECT_ID(‘test’) is not null\ndrop table test\ngo\ncreate table test\n(\ni int identity(1,1)\n,c varchar(255)\n)\ngo\ninsert into test (c)\nselect ‘a’\nunion all\nselect ‘b’\ngo 100\nselect i%2, replace(replace(max(b.list),”,”),”,”) as sum_c\nfrom test a\ncross apply (\nselect c + ‘,’ as c\nfrom test\nwhere i%2 = a.i%2\nfor xml path(”)\n) b (list)\ngroup by a.i%2\ngo\n","date":"2011-03-08T05:42:41-08:00","permalink":"/2011/03/08/concatenate-string-value-in-sql/","title":"concatenate string value in SQL"},{"content":"http://technet.microsoft.com/en-us/library/bb545450.aspx\n\u0026lt;SQL 2008 R2\u0026gt;\nhttp://technet.microsoft.com/en-us/library/bb418445%28SQL.10%29.aspx\n\u0026lt;SQL 2008\u0026gt;\nhttp://technet.microsoft.com/en-us/library/dd631815%28SQL.10%29.aspx\n\u0026lt;SQL 2005\u0026gt;\nhttp://technet.microsoft.com/en-us/library/ee229559%28SQL.10%29.aspx\nhttp://technet.microsoft.com/en-us/library/ff928326%28SQL.10%29.aspx\n","date":"2011-03-07T01:54:09-08:00","permalink":"/2011/03/07/msdn-technical-articles-for-sql-servers/","title":"MSDN Technical Articles for SQL servers."},{"content":"The Database Administrator’s Guide to the SQL Server Database Engine .NET Common Language Runtime Environment http://www.sqlskills.com/resources/Whitepapers/SQL%20Server%20DBA%20Guide%20to%20SQLCLR.htm\nIf you use linked server queries, you need to read this…. http://blogs.msdn.com/psssql/archive/2009/09/22/if-you-use-linked-server-queries-you-need-to-read-this.aspx\nHow It Works: DBCC MemoryStatus Locked Pages Allocated and SinglePageAllocator Values http://blogs.msdn.com/psssql/archive/2009/05/15/how-it-works-dbcc-memorystatus-locked-pages-allocated-and-singlepageallocator-values.aspx\nI had log backup jobs setup which started to fail intermittently for last couple of weeks. The SQL server complained of “insufficient system memory”. The jobs were backed up as part of maintenance plan – maxtransfersize option http://www.sqlservercentral.com/Forums/Topic362968-24-1.aspx\nHow to find who is using / eating up the Virtual Address Space on your SQL Server http://blogs.msdn.com/sqlserverfaq/archive/2010/02/16/how-to-find-who-is-using-eating-up-the-virtual-address-space-on-your-sql-server.aspx\nVirtualAlloc Function http://msdn.microsoft.com/en-us/library/aa366887%28VS.85%29.aspx\nSQL Server encounters memory pressure and generate 701 Error due to incorrect configuration of Service Broker http://blogs.msdn.com/sqlserverfaq/archive/2010/03/25/sql-server-encounters-memory-pressure-and-generate-701-error-due-to-incorrect-configuration-of-service-broker.aspx\nSQLOS’s memory manager and SQL Server’s Buffer Pool http://blogs.msdn.com/slavao/archive/2005/02/11/371063.aspx\nFAIL_VIRTUAL_RESERVE http://www.sqlservercentral.com/Forums/Topic432976-360-1.aspx\nFix for “Failed Virtual Allocate Bytes” error? – Service Broker problem http://social.msdn.microsoft.com/Forums/en/sqlservicebroker/thread/1d527f9e-5497-4e02-a2b2-f0ee3a386326\nFIX: Error message when you use SQL Server Service Broker in SQL Server 2005: “Failed Virtual Allocate Bytes: FAIL_VIRTUAL_RESERVE 589824” http://support.microsoft.com/default.aspx?scid=kb;en-us;959007\nINF: Using DBCC MEMORYSTATUS to Monitor SQL Server Memory Usage http://support.microsoft.com/kb/271624\nServer Memory Options http://msdn.microsoft.com/en-us/library/ms178067.aspx\nVarious memory errors are logged to SQL Server error log when using SQL CLR objects http://support.microsoft.com/kb/969962\nFIX: The memory usage of a SQL Server service increases quickly when you run a query that uses a linked server in SQL Server 2005 or in SQL Server 2008 http://support.microsoft.com/kb/971622\nAppDomain marked for unload due to memory pressure- Jonathan Kehayias\nhttp://social.msdn.microsoft.com/Forums/en/sqlnetfx/thread/e5ca2988-df87-4ce4-8fb7-b338a81a390e\nhelp with this AppDomain event- Jonathan Kehayias\nhttp://social.msdn.microsoft.com/forums/en-US/sqlnetfx/thread/cc1b3e43-0db8-4e75-b5ab-bc2a4c93b12b/\nSQL Server 2005: CLR Integration\nhttp://blogs.msdn.com/sqlclr/archive/2006/03/24/560154.aspx\nUsing the SQL Server Service Startup Options http://msdn.microsoft.com/en-us/library/ms190737.aspx\nCome on 64bit so we can leave the mem…. – Bob Ward\nhttp://blogs.msdn.com/b/psssql/archive/2009/08/26/come-on-64bit-so-we-can-leave-the-mem.aspx\n–Simon Cho\nComments (archived from WordPress) Fran · 2011-10-14\nRecently we encountered memory on our x64 SQL 2008 R2 server. Your site covers lots of the errors we have. Thank you so much for putting them in one place!\nSimon Cho · 2011-10-24\nThank you for your visit. If you have any question, please send email.\nSimon@simonsql.com\n","date":"2011-03-07T01:47:58-08:00","permalink":"/2011/03/07/all-information-about-sql-memory-to-leave-area-also-called-mtl-or-memory-to-reserve/","title":"all information about SQL “Memory To Leave” area (also called MTL or “Memory To Reserve”)."},{"content":"Hi all,\nThis is my first blog for publishing SQL article.\nI’ll update SQL stuff here.\nThanks.\n","date":"2011-03-07T08:09:21Z","permalink":"/2011/03/07/hello-world/","title":"First article"}]