I downloaded and installed AdventureWorks db for sql server 2008. Are there any exercises or tutorials for it? I’d like to to practice SQL select statements
Tag: sql-server
How do I UPDATE from a SELECT in SQL Server?
In SQL Server, it is possible to insert rows into a table with an INSERT.. SELECT statement: Is it also possible to update a table with SELECT? I have a temporary table containing the values and would like to update another table using those values. Perhaps something like this: Answer
Is there a severe performance hit for using Foreign Keys in SQL Server?
I’m trying my best to persuade my boss into letting us use foreign keys in our databases – so far without luck. He claims it costs a significant amount of performance, and says we’ll just have jobs to cleanup the invalid references now and then. Obviously this doesn’t work in practice, and the database is flooded with invalid references. Does
Benefits Of Using SQL Ordinal Position Notation?
Background Information Ordinal position notation, AKA ordinals, is column shorthand based on the column order in the list of columns in the SELECT clause, instead of either the column name or column alias. Commonly supported in the ORDER BY clause, some databases (MySQL 3.23+, PostgreSQL 8.0+) support the syntax for the GROUP BY clause as well. Here’s an example of
SQL Inner Join On Null Values
I have a Join Isnull in a Join like this makes it slow. It’s like having a conditional Join. Is there any work around to something like this? I have a lot of records where QID is Null Anyone have a work around that doesn’t entail modifying the data Answer You have two options or easier
SQL Management Studio won’t recognize a table exists after scripted create
So if I create a new table in the query editor in SQL Management Studio after hitting refresh on the DB I can see and work with that table. However if I want to run another query referencign that table from withen the query editor it doesn’t reconize that table exists. I’ve tried hitting refresh at the DB level, and
Help finding old SQL tool that rewrote queries [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 7 years ago. Improve this question There was this old sql server tool called Lectoneth or something like that, you’d put sql queries in it, and it would rewrite it
Check if role exists in DB?
I want to add users to the same role in more than one database. However the role may or may not be present in each database. How can I check if the role exists in each database and if it does, add users to that role? e.g. IF role exists BEGIN Add user in role END Answer try:
Finding duplicate rows in SQL Server
I have a SQL Server database of organizations, and there are many duplicate rows. I want to run a select statement to grab all of these and the amount of dupes, but also return the ids that are associated with each organization. A statement like: Will return something like But I’d also like to grab the IDs of them. Is
How to create a summary view from multiple views?
Given I have the following view where N=1..100 Currently we have summary views which insert to a table like The table is then used to create an overall summary like Is there a way to create summary_view_all_plants without having to create each individual summary_view_N? I would like to be able to iterate though a list of reports and dynamically generate