UPDATE/ADD/ALTER Column and Table in SQL

UPDATE Table

The following SQL statement updates the first customer (CustomerID = 1) with a new contact person and a new city.

Example

UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
WHERE CustomerID = 1;

UPDATE Multiple Records

It is the WHERE clause that determines how many records that will be updated.

The following SQL statement will update the contactname to “Juan” for all records where country is “Mexico”:

Example

UPDATE Customers
SET ContactName='Juan'
WHERE Country='Mexico';

Update Warning!

Be careful when updating records. If you omit the WHERE clause, ALL records will be updated!

Example

UPDATE Customers
SET ContactName='Juan';

ALTER TABLE – ADD Column

To add a column in a table, use the following syntax:

ALTER TABLE table_name
ADD column_name datatype;

ALTER TABLE – ALTER/MODIFY COLUMN

To change the data type of a column in a table, use the following syntax:

SQL Server / MS Access:

ALTER TABLE table_name
ALTER COLUMN column_name datatype;

DELETE COLUMN/TABLE TABLE

DELETE FROM Customers
WHERE CustomerName='Alfreds Futterkiste';

DELETE FROM table_name
WHERE condition;

Delete All Records

DELETE * FROM table_name;

ALTER TABLE – DROP COLUMN

To delete a column in a table, use the following syntax (notice that some database systems don’t allow deleting a column):

ALTER TABLE table_name
DROP COLUMN column_name;

Part 2:How to Set Up a Virtual Machine

Setting Up a Virtual Machine

Once you’ve decided on a VM app and gotten it installed, setting up a VM is actually pretty easy. We’re going to run through the basic process in VirtualBox, but most apps handle creating a VM the same way.

Open up your VM app and click the button to create a new virtual machine.

You’ll be guided through the process by a wizard that first asks which OS you’ll be installing. If you type the name of the OS in the “Name” box, the app will most likely automatically select the type and version for the OS. If it doesn’t—or it guesses wrong—select those items yourself from the dropdown menus. When you’re done, click “Next.”

Based on the OS you plan to install, the wizard will preselect some default settings for you, but you can change them over the screens that follow. You’ll be asked how much memory to allocate to the VM. If you want something other than the default, select it here. Otherwise, just click “Next.” And don’t worry, you’ll be able to change this value later if you need to.

The wizard will also create the virtual hard disk file to be used by the VM. Unless you already have a virtual hard disk file you want to use, just select the option to create a new one.

You’ll also be asked whether to create a dynamically allocated or fixed size disk. With a dynamically allocated disk, you’ll set a maximum disk size, but the file will only grow to that size as it needs to. With a fixed size disk, you’ll also set a size, but the file created will be that large from its creation.

We recommend creating fixed size disks because, while they eat up a little more disk space, they also perform better—making your VM feel a bit more responsive. Plus, you’ll know how much disk space you’ve used and won’t get surprised when your VM files start growing.

You’ll then be able to set the size of the virtual disk. You’re free to go with the default setting or change the size to suit your needs. Once you click “Create,” the virtual hard disk is created.

After that, you’re dumped back into the main VM app window, where your new VM should show up. Make sure the installation media you need is available to the machine—usually this involves pointing to an ISO file or real disc through the VM’s settings. You can run your new VM by selecting it and hitting “Start.”


Of course, we’ve just touched on the basics of using VMs here. If you’re interested in more reading, check out some of our other guides:

https://www.howtogeek.com/196060/beginner-geek-how-to-create-and-use-virtual-machines/

Part 1:How to Create and Use Virtual Machines

Virtual machines allow you to run an operating system in an app window on your desktop that behaves like a full, separate computer. You can use them play around with different operating systems, run software your main operating system can’t, and try out apps in a safe, sandboxed environment.

There are several good free virtual machine (VM) apps out there, which makes setting up a virtual machine something anybody can do. You’ll need to install a VM app, and have access to installation media for the operating system you want to install.

What’s a Virtual Machine?

A virtual machine app creates a virtualized environment—called, simply enough, a virtual machine—that behaves like a separate computer system, complete with virtual hardware devices. The VM runs as a process in a window on your current operating system. You can boot an operating system installer disc (or live CD) inside the virtual machine, and the operating system will be “tricked” into thinking it’s running on a real computer. It will install and run just as it would on a real, physical machine. Whenever you want to use the operating system, you can open the virtual machine program and use it in a window on your current desktop.

In the VM world, the operating system actually running on your computer is called the host and any operating systems running inside VMs are called guests. It helps keep things from getting too confusing.

In a particular VM, the guest OS is stored on a virtual hard drive—a big, multi-gigabyte file stored on your real hard drive. The VM app presents this file the guest OS as a real hard drive. This means you won’t have to mess around with partitioning or doing anything else complicated with your real hard drive.

Virtualization does add some overhead, so don’t expect them to be as fast as if you had installed the operating system on real hardware. Demanding games or other apps that require serious graphics and CPU power don’t really do so well, so virtual machines aren’t the ideal way to play Windows PC games on Linux or Mac OS X—at least, not unless those games are much older or aren’t graphically demanding.

The limit to how many VMs you can have are really just limited by the amount of hard drive space. Here’s a peek at some of the VMs we use when testing things out while writing articles. As you can see, we’ve got full VMs with several versions of Windows and Ubuntu installed.

You can also run multiple VMs at the same time, but you’ll find yourself somewhat limited by your system resources. Each VM eats up some CPU time, RAM, and other resources.

Why You’d Want to Create a Virtual Machine

Aside from being good geeky fun to play around with, VMs offer a number of serious uses. They allow you to experiment with another OS without having to install it on your physical hardware. For example, they are a great way to mess around with Linux—or a new Linux distribution—and see if it feels right for you. When you’re done playing with an OS, you can just delete the VM.

VMs also provide a way to run another OS’ software. For example, as a Linux or Mac user, you could install Windows in a VM to run Windows apps you might not otherwise have access to. If you want to run a later version of Windows—like Windows 10—but have older apps that only run on XP, you could install Windows XP into a VM.

Another advantage VMs provide is that they are “sandboxed” from the rest of your system. Software inside a VM can’t escape the VM to tamper with the rest of your system. This makes VMs a safe place to test apps—or websites—you don’t trust and see what they do.

For example, when the “Hi, we’re from Windows” scammers came calling, we ran their software in a VM to see what they would actually do—the VM prevented the scammers from accessing our computer’s real operating system and files.

Sandboxing also allows you to run insecure OSes more safely. If you still need Windows XP for older apps, you could run it in a VM where at least the harm of running an old, unsupported OS is mitigated.

Virtual Machine Apps

There are several different virtual machine programs you can choose from:

  • VirtualBox: (Windows, Linux, Mac OS X): VirtualBox is very popular because it’s open-source and completely free. There’s no paid version of VirtualBox, so you don’t have to deal with the usual “upgrade to get more features” upsells and nags. VirtualBox works very well, particularly on Windows and Linux where there’s less competition, making it a good place to start with VMs.
  • VMware Player: (Windows, Linux): VMware has their own line of virtual machine programs. You can use VMware Player on Windows or Linux as a free, basic virtual machine tool. More advanced features—many of which are found in VirtualBox for free—require upgrading to the paid VMware Workstation program. We recommend starting out with VirtualBox, but if it doesn’t work properly you may want to try VMware Player.
  • VMware Fusion: (Mac OS X): Mac users must buy VMware Fusion to use a VMware product, since the free VMware Player isn’t available on a Mac. However, VMware Fusion is more polished.
  • Parallels Desktop: (Mac OS X): Macs also have Parallels Desktop available. Both Parallels Desktop and VMware Fusion for Mac are more polished than the virtual machine programs on other platforms, since they’re marketed to average Mac users who might want to run Windows software.

While VirtualBox works very well on Windows and Linux, Mac users may want to buy a more polished, integrated Parallels Desktop or VMware Fusion program. Windows and Linux tools like VirtualBox and VMware Player tend to be targeted to a geekier audience.

There are many more VM options, of course. Linux includes KVM, an integrated virtualization solution. Professional and Enterprise version of Windows 8 and 10—but not Windows 7—include Microsoft’s Hyper-V, another integrated virtual machine solution. These solutions can work well, but they don’t have the most user-friendly interfaces.

https://www.howtogeek.com/196060/beginner-geek-how-to-create-and-use-virtual-machines/

The integration of SSRS and Power BI

The integration of SSRS and Power BI creates a single portal to access all reporting items; which would be from Power BI dashboard.

For using this functionality, some requirements need to be met. You have to use SQL Server 2016 or higher version. Your dataset of the report should be using saved credentials. SSRS report should have charts, gauges, or maps, because only charts, gauges, and maps can be pinned to the dashboard. Power BI Integration in the reporting services configuration manager should be enabled. And finally; SQL Server agent should be up and running because Agent is responsible for keeping that tile up to date.

Using the integration of SSRS and Power BI; you can have tiles in Power BI dashboard which points to SSRS reports for the detailed paginated report. Power BI users will use normal tiles for interactive reports, and they can use SSRS tiles when they want to see the more detailed paginated report in SSRS.

Terminology: High-Level and Low-Level

High-level and low-level, as technical terms, are used to classify, describe and point to specific goals of a systematic operation; and are applied in a wide range of contexts, such as, for instance, in domains as widely varied as computer science and business administration.

High-level describe those operations that are more abstract in nature; wherein the overall goals and systemic features are typically more concerned with the wider, macro system as a whole.

Low-level describes more specific individual components of a systematic operation, focusing on the details of rudimentary micro functions rather than macro, complex processes. Low-level classification is typically more concerned with individual components within the system and how they operate.

In Computer Science, software is typically divided into two types: high-level end-user applications software (such as word processors, databases, video games, etc.), and low-level systems software (such as operation systems, hardware drivers, etc.).
As such, high-level applications typically rely on low-level applications to function.
In terms of programming, a high-level programming language is one which has a relatively high level of abstraction and manipulates conceptual functions in a structured manner.
low-level programming language is one like assembly language that contains rudimentary microprocessor commands.

 

https://en.wikipedia.org/wiki/High-_and_low-level

SQL Inteview Questions

--CREATE a TABLE FOR INCREMENTAL NUMBBER FROM 1 to 1000
CREATE TABLE dbo.TEST_NUMBER (IncrNum int NOT NULL)
;
--INSERT VALUES USING LOOP
DECLARE @first AS INT
SET @first = 1
DECLARE @step AS INT
SET @step = 1
DECLARE @last AS INT
SET @last = 1000

BEGIN TRANSACTION
WHILE(@first <= @last) BEGIN INSERT INTO TEST_NUMBER VALUES(@first) SET @first += @step

END COMMIT TRANSACTION

-- SELECT TOP 1000 ROWS 
SELECT TOP (1000) [IncrNum]
 FROM [dbo].[TEST_NUMBER]

-- SELECT [IncrNum] FROM 1 to 1000
SELECT *
FROM [dbo].[TEST_NUMBER]
WHERE [IncrNum] <= 1000

-- SELECT ODD NUMBERS
SELECT *
FROM [dbo].[TEST_NUMBER]
WHERE [IncrNum] <= 1000
AND ([IncrNum] % 2 <> 0)