SQL INSERT Statement #sql #insert #statement, #sql #insert #command, #sql #query #insert


Beginner SQL Tutorial

Learning SQL

Other SQL Tutorial

SQL INSERT Statement

The INSERT Statement is used to add new rows of data to a table.

We can insert data to a table in two ways,

1) Inserting the data directly to a table.

Syntax for SQL INSERT is:

[ (col1, col2, col3. colN)]
VALUES (value1, value2, value3. valueN);

  • col1, col2. colN — the names of the columns in the table into which you want to insert data.

While inserting a row, if you are adding value for all the columns of the table you need not specify the column(s) name in the sql query. But you need to make sure the order of the values is in the same order as the columns in the table. The sql insert query will be as follows

VALUES (value1, value2, value3. valueN);

For Example: If you want to insert a row to the employee table, the query would be like,

INSERT INTO employee (id, name, dept, age, salary location) VALUES (105, ‘Srinath’, ‘Aeronautics’, 27, 33000);

NOTE: When adding a row, only the characters or date values should be enclosed with single quotes.

If you are inserting data to all the columns, the column names can be omitted. The above insert statement can also be written as,

INSERT INTO employee
VALUES (105, ‘Srinath’, ‘Aeronautics’, 27, 33000);

Inserting data to a table through a select statement.

Syntax for SQL INSERT is:

INSERT INTO table_name
[(column1, column2. columnN)]
SELECT column1, column2. columnN
FROM table_name [WHERE condition];

For Example: To insert a row into the employee table from a temporary table, the sql insert query would be like,

INSERT INTO employee (id, name, dept, age, salary location) SELECT emp_id, emp_name, dept, age, salary, location
FROM temp_employee;

If you are inserting data to all the columns, the above insert statement can also be written as,

INSERT INTO employee
SELECT * FROM temp_employee;

NOTE: We have assumed the temp_employee table has columns emp_id, emp_name, dept, age, salary, location in the above given order and the same datatype.

1) When adding a new row, you should ensure the datatype of the value and the column matches

2) You follow the integrity constraints, if any, defined for the table.

Synovial Fluid Analysis #synovial #fluid #analysis, # #2006 #21st #abnormal #abnormally #activities


Synovial Fluid Analysis

Synovial fluid analysis is a group of tests that examine joint (synovial) fluid. The tests help diagnose and treat joint-related problems.

Alternative Names

Joint fluid analysis; Joint fluid aspiration

How the test is performed

A sample of synovial fluid is needed for this test. Synovial fluid is normally a thick, straw-colored liquid found in small amounts in joints, bursae, and tendon sheaths.

After the area is cleaned, the health care provider will insert a sterile needle through the skin and into the joint space. Once in the joint, fluid is drawn through the needle into a sterile syringe.

The fluid sample is sent to the laboratory. The laboratory technician will check the sample’s color and clarity, and then place it under a microscope to check it for red and white blood cells, crystals (in the case of gout), and bacteria. In addition, there may be a chemical analysis, and if infection is a concern, a sample will be cultured to see if any bacteria grow.

How to prepare for the test

Normally, no special preparation is necessary, but contact your health care provider before the test to make sure. Tell your doctor if you are taking blood thinners, as they can affect test results.

How the test will feel

Occasionally, the health care provider will first inject local anesthesia with a small needle, which will sting. The aspiration is done with a larger needle and may also cause some pain. The procedure usually lasts less than one minute.

Why the test is performed

The test can help diagnose the cause of pain or swelling in joints. Removing the fluid can also help relieve joint pain.

This test may be used to diagnose:

  • Gout
  • Infection
  • Other inflammatory joint conditions
  • Joint injury
  • Osteoarthritis

What abnormal results mean

Abnormal joint fluid may look cloudy or abnormally thick.

Blood in the joint fluid may be a sign of injury inside the joint or a body-wide bleeding problem. An excess amount of normal synovial fluid can also be a sign of osteoarthritis.

What the risks are

  • Infection of the joint — unusual but more common with repeated aspirations
  • Bleeding into the joint space

Special considerations

Ice or cold packs may be applied to the joint for 24 to 36 hours after the test to reduce the swelling and joint pain. Depending on the exact problem, you can probably resume your normal activities after the procedure. Talk to your health care provider to determine what activity is most appropriate for you.


Knight JA, Kjeldsberg CR. Cerebrospinal, synovial, and serous body fluids. In: McPherson RA, Pincus MR, eds. Henry’s Clinical Diagnosis and Management by Laboratory Methods. 21st ed. Philadelphia, Pa: Saunders Elsevier; 2006:chap 28.

Review Date: 7/10/2009

The information provided herein should not be used during any medical emergency or for the diagnosis or treatment of any medical condition. A licensed physician should be consulted for diagnosis and treatment of any and all medical conditions. Call 911 for all medical emergencies. Links to other sites are provided for information only — they do not constitute endorsements of those other sites. Copyright 2010 A.D.A.M. Inc. as modified by University of California San Francisco. Any duplication or distribution of the information contained herein is strictly prohibited.

Information developed by A.D.A.M. Inc. regarding tests and test results may not directly correspond with information provided by UCSF Medical Center. Please discuss with your doctor any questions or concerns you may have.

Getting Care

Using a SQL Server Logon Trigger #sql #server #consulting, #database #administration, #sql


One of my customers has an instance where many people log in as sa. We’re planning to change the password and rename the sa login, but we first need to know who is using it, and for what. To do this, I’ve put together an sa Logon Trigger. While I typically avoid triggers, I believe this one is very manageable because it is specific to only one login, and it is only collecting details from each login attempt.

First I create a LogonAudit table to collect the logon details.


But wait. We logged in one time, and we have more than one entry recorded in our LogonAudit table. Why? This happens because there are multiple SQL Server Services running in parallel. If you were to go in and stop all SQL Server Services except for SQL Server (MSSQLSERVER). then you would only capture one entry in the table for each login attempt.

Maybe you want to disable it for some reason? Rather than deleting it, you can just DISABLE/ENABLE with these statements:



See more details here regarding the SQL Server Logon Trigger:


Thanks for your post, in my experience logon triggers can become really expensive to the point of creating serious performance issues depending on the number of logon events happening.

A small improvement you can do in this trigger is first of all validate

that way you can exit the trigger without further action in 99.9% of the cases. (unless you have everyone using sa , of course)

Processing the xml and then asking would be a waste of resources.

Great script, but instead of logging it to a table we put it into the SQL logs. This change meant I would not need to manage another db on my servers; by using exec xp_logevent we achieve the same as a table and it seems to work quite well for our means and tracks the users that need to be tracked.