Structured Query Language

It should possibly be noted that just about all of these notes and links come from my experience with MS-SQL server, a glancing familiarity with MySQL and a complete unfamiliarity with Oracle. And NoSQL? uh, whut?

The steps worked great. However, the code uses C:\temp by default, and I followed it to the letter the first time I ran it, not knowing if SQL-Server would move the files to another location or not. Turned out to be not.

-- step 2-- only the two "LogicalNames" are important-- TODO: uh, we are not actual grabbing these with this method....-- ASSUMPTION: names are [dbname] and [dbname]_log
RESTORE FILELISTONLYFROM DISK = ''' + @bakpath + @dbname + '.bak''--GO

Save not permitted

To change this option, on the Tools menu, click Options, expand Designers, and then click Table and Database Designers. Select or clear the Prevent saving changes that require the table to be re-created check box.

Sample queries

These are not presented as beginners queries (though they may be) to teach basic SQL.
Rather, these are snippets I found useful at various times, and kept forgetting.
Maybe I remember them, maybe I don’t.
Here they are.

Returning the autoincrementing column of a newly added record.

The following Query will add a new record and then return (as per a select statement) the value assigned to the ID column (that is, the column that automatically provides a unique ID for each new record).

creating indexes

View an existing index via sp_helpindex <tablename>

Notes for Not Null

You cannot add a Not Null constraint to an existing table unless you first add the column as nullable, then backfill the values. Then, once that is complete, can do an alter table/alter column in T-SQL. This is the preferred method over using SQL Mgmt Studio since it will try to recreate the entire table if you later add a not null constraint.

handling occasional deadlocks

I was talking to Wilce the other day about how to handle queries that occasionally fail because of deadlocks, and I told him about this SQL I found on the web.
It looks like a stored procedure, but really it’s just regular T-SQL that can be executed just like any other query.
What you do is add your SQL to the query below, and it will try to run your query in a transaction.
If it fails due to a deadlock, it will try again, up to 3 times.
The nice thing about it is that you don’t have to add any transaction / rollback / retry code to your program - it’s all handled in SQL Server.

ciAlis Vs ViAGra

hi

Useful information with full of technical news. Nice one. I am really very happy with the part of this blog.
https://www.gangboard.com/big-data-training/data-science-training(approve sites)https://www.gangboard.com/big-data-training/hadoop-admin-training(approve sites)

melbahenry - 26.09.2016 - 03:27

This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am
not the only one having all the enjoyment here! keep up the good work. <a href=“http://www.gangboard.com/software-testing-training/selenium-training(approve sites)”>Selenium Online Training</a>