AND / OR  truth table in SQL

why null is introduced in the AND and OR truth table?when will a statement/part of a statement return a null value??
|AND               |True          |False             |NULL??        |
|True               |True          |False             |Null             |
|False              |False          |False             |False           |
|Null                |Null             |Null               |Null             |is it introduced in AND/OR truth table for the null containing row(s)??
select employee_id,last_name,job_id,salary
from employees
wheere salary >= 1000
And job_id like '%man%';
how the statement after the where cluz can return null value??Edited by: sayantan chakraborty on Aug 14, 2009 11:36 AM

sayantan chakraborty wrote:
how either of X and Y will return a null value?can you put any example?is there any syntax/ command which will print the return value of a statement as null?Say you had a table with columns X and Y. As long as NOT NULL constraints WERE NOT defined these values could contain NULLs. Then if you apply the WHERE condition of X = Y you would have the case of NULL = NULL which results in UNKNOWN.
Simple Example:
SQL > WITH test_data AS
  2  (
  3          SELECT 1 AS X, 1 AS Y FROM DUAL UNION ALL
  4          SELECT 2 AS X, 2 AS Y FROM DUAL UNION ALL
  5          SELECT 3 AS X, 5 AS Y FROM DUAL UNION ALL
  6          SELECT 4 AS X, 6 AS Y FROM DUAL UNION ALL
  7          SELECT 1 AS X, NULL AS Y FROM DUAL
  8  )
  9  SELECT  *
10  FROM    test_data
11  WHERE   X = Y
12  /
         X          Y
         1          1
         2          2

Similar Messages

  • AND/OR TRUTH TABLE.

    Is there any explanation for why
    1) TRUE AND NULL = NULL
    2) FALSE AND NULL = FALSE
    3) TRUE OR NULL = TRUE
    4) FALSE OR NULL = NULL
    Thank you,
    Narendra

    Just to diagramatically show what Toon has explained...
    It becomes clear if you jot down the logic tables and look at them yourself...
    ..X.. ..Y..  .AND.
    TRUE  TRUE   TRUE
    TRUE  FALSE  FALSE
    FALSE TRUE   FALSE
    FALSE FALSE  FALSEIf X is FALSE it doesn't matter if Y is unknown (NULL) because we know the truth table for AND
    always gives a result of FALSE if X is FALSE. (no.2 in your list)
    If X is TRUE, the result of AND logic becomes dependant on Y. If Y is unknown (NULL) then, the
    answer is also unknown. (no.1 in your list)
    ..X.. ..Y..  .OR..
    TRUE  TRUE   TRUE
    TRUE  FALSE  TRUE
    FALSE TRUE   TRUE
    FALSE FALSE  FALSEIf X is TRUE it doesn't matter if Y is unknown (NULL) because we know the truth table for OR
    always gives a result of TRUE if X is TRUE. (no.3 in your list)
    If X is FALSE, the result of OR logic becomes dependant on Y. If Y is unknown (NULL) then, the
    answer is also unknown (no.4 in your list)

  • Extract Data from XML and Load into table using SQL*Loader

    Hi All,
    We have a XML file (sample.xml) which contains credit card transaction information. We have a standard SQL*Loader control file which loads the data from a flat file and the control file code is written as position based method. Our requirement is to use this control file as per our requirement(i.e) load the data into the table from our XML file), But we need help in converting the XML to a flat file or Extract the data from the XML tags and pass the information to the control file and in turn it loads the table.
    Your suggestion is highly appreciated.
    Thanks in advance

    Hi,
    First of all go to PSA maintanance ( Where you will see PSA records ).
    Goto list---> Save-> File---> Spreadsheet (Choose Radio Button)
    > Give the proper file name where you want to download and then-----> Generate.
    You will get ur PSA data in Excel Format.
    Thanks
    Mayank

  • Need Guide to create a table in SQL Server and Process data for JDBC

    Dear All,
    Scenario:JDBC to JDBC
    I need to practice JDBC to JDBC scenario and for that i need to create a table in SQL server for sender ,receiver and update  i have installed SQL Server and no idea about creation of table and Connection string for PI.
    I want you to explain each and every step for the Table Creation ,Driver and connection string.
    Thanks in Advance.

    Try searchin in the forum and then google. This forum is not for teaching the basics.
    VJ

  • Need To Create a table in Sql Server and do some culculation into the table from Oracle and Sql

    Hello All,
    I'm moving a data from Oracle to Sql Server with ETL (80 tables with data) and i want to track the number of records that i moving on the daily basis , so i need to create a table in SQL Server, wilth 4 columns , Table name, OracleRowsCount, SqlRowCount,
    and Diff(OracleRowsCount - SqlRowCount) that will tell me the each table how many rows i have in Oracle, how many rows i have in SQL after ETL load, and different between them, something like that:
    Table Name  OracleRowsCount   SqlRowCount  Diff
    Customer                150                 150            
    0
    Sales                      2000                1998          
    2
    Devisions                 5                       5             
    0
    (I can add alot of SQL Tasks and variables per each table but it not seems logicly to do that, i tryid to find a way to deal with that in vb but i didn't find)
    What the simplest way to do it ?
    Thank you
    Best Regards
    Daniel

    Hi Daniel,
    According to your description, what you want is an indicator to show whether all the rows are inserted to the destination table. To achieve your goal, you can add a Row Count Transformation following the OLE DB Destination, and redirect bad rows to the Row
    Count Transformation. This way, we can get the count of the bad rows without redirecting these rows. Since the row count value is stored in a variable, we can create another string type variable to retrieve the row count value from the variable used by the
    Row Count Transformation, and then use a Send Mail Task to send the row count value in an email message body. You can also insert the row count value to the SQL Server table through Execute SQL Task. Then, you can check whether bad rows were generated in the
    package by querying this table.  
    Regards,
    Mike Yin
    TechNet Community Support

  • How to pass and work with a PL/SQL or Temp table in a Procedure?

    My problem is that I have a query that involves about 10 tables or so, but everything starts from one base table. I am trying to split the base table so that the query actually finishes.
    Problem Query:
    with base_table as
    select * from table_a
    , t1 as
      select * from table_b
    -- There are some manipulation in the SQL, but not listing it here.
    , t2 as
      select * from table_c INNER JOIN t1 on t1.id = table_c.id
    ) What I want to do is limit base table and thus create a procedure such that it evalutes a temporary table and the temporary table will be limited by 1000 rows or so.
    Thanks for your help.

    Currently I am using:
    DECLARE
       l_start                       NUMBER;
       l_increment                   NUMBER;
       l_max                         NUMBER;
    BEGIN
       l_start := 1;
       l_increment := 100;
       SELECT COUNT(*) AS the_count
         INTO l_max
         FROM table_a;
       LOOP
       INSERT INTO new_table
         WITH base_table AS
         (SELECT p.*
            FROM (SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
                    FROM table_a a) p
           WHERE rnum BETWEEN l_start AND l_start + l_increment - 1)
       , t1 AS
         (SELECT *
            FROM table_b
    -- There are some manipulation in the SQL, but not listing it here.
       , t2 AS
         (SELECT *
            FROM table_c INNER JOIN t1 ON t1.ID = table_c.ID
    SELECT *
      FROM t2, temp_base;
    COMMIT;
          l_start := l_start + l_increment;
          EXIT WHEN l_start > l_max;
       END LOOP;Is it better to create a Temporary table or pass the data as a cursor:
    SELECT DENSE_RANK () OVER (ORDER BY alpha_id) rnum, a.*
    FROM table_a a
    Thanks.

  • Deleted Table in SQL and DBML still remained relation !!!!

    Hi Dear Experts
    I've faced the serious problem please help me :( !
    I've deleted a table from SQL database and also dbml and i created new table instead
    Also in Store Procedure the new table is used
    I've checked that the old table has completely removed
    but when in want to excecute the solution (the SP it tells me that previous relation (Foreignkey )
    is still remained ?!!!!!!) 
    ***THE OLD TABLE WAS IN RELATION WITH A TABLE IN SP BUT NOW IS IN RELATION WITH NEW TABLE*****
    Why this error occured even i've have removed the table?????
    Thanks a lot

    Error Message
    the insert statment Confilicted with foreign key constarint "FK_<tableName>_<oldtable>".the conflict occurred in database,table<old table>,column'x'
    thanks a lot
    Hi nasringh,
    Could you please check the relationship and the underlying records between foreign key table and primary key table? We must insert Data into the parent table which containing the Primary Key, before attempting to insert data into the child table containing
    the Foreign Key.
    For more detail information, please take a look at the following similar thread:
    http://stackoverflow.com/questions/2965837/insert-statement-conflicted-with-the-foreign-key-constraint
    http://www.codeproject.com/Questions/281774/The-INSERT-statement-conflicted-with-the-FOREIGN-K
    Regards,
    Elvis Long
    TechNet Community Support

  • How can we find the most usage and lowest usage of table in Sql Server by T-SQL

    how can we find the most usage and lowest usage of table in Sql Server by T-SQL
    The table has time stamp column
    StartedOn datetime
    EndedOn datetime

    The Below query has been used , but the textdata column doesnot include the name of the table ServiceLog.
    SELECT
    FROM
    databasename,
    duration
    fn_trace_gettable('F:\Program
    Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Log\log_148.trc',
    default)
    WHERE
    DATABASENAME='ZTCFUTURE'
    AND TEXTDATA
    IS
    NOT
    NULL
    --AND TEXTDATA LIKE 'SERVICE%'
    order
    by cpu
    desc; 

  • Creating tables on SQL studio and viewing the table in the SAP system

    i have just created a table using the SQL studio and wants to use it view it in the SAP system using the SAP logon. till now i have not found a way to create it therefore any help is much appreciated.

    Hmm... you want to see tables via SAPLogon ??
    Ok, let's assume you really want to access tables via ABAP instead.
    For that you've two options:
    1. Create the table in the ABAP dictonary (SE11) exactly like you created it in the database and activate the table.
    After that you can access the table via SE16 or any ABAP as you like.
    2. You don't create the table in the ABAP dictonary and use native SQL to access the data.
    Neither of these options is meant to be the way to do it.
    The correct way would be to design the whole table in the ABAP dictionary and create the table on the database from that.
    regards,
    Lars

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How can one  read a Excel File and Upload into Table using Pl/SQL Code.

    How can one read a Excel File and Upload into Table using Pl/SQL Code.
    1. Excel File is on My PC.
    2. And I want to write a Stored Procedure or Package to do that.
    3. DataBase is on Other Server. Client-Server Environment.
    4. I am Using Toad or PlSql developer tool.

    If you would like to create a package/procedure in order to solve this problem consider using the UTL_FILE in built package, here are a few steps to get you going:
    1. Get your DBA to create directory object in oracle using the following command:
    create directory TEST_DIR as ‘directory_path’;
    Note: This directory is on the server.
    2. Grant read,write on directory directory_object_name to username;
    You can find out the directory_object_name value from dba_directories view if you are using the system user account.
    3. Logon as the user as mentioned above.
    Sample code read plain text file code, you can modify this code to suit your need (i.e. read a csv file)
    function getData(p_filename in varchar2,
    p_filepath in varchar2
    ) RETURN VARCHAR2 is
    input_file utl_file.file_type;
    --declare a buffer to read text data
    input_buffer varchar2(4000);
    begin
    --using the UTL_FILE in built package
    input_file := utl_file.fopen(p_filepath, p_filename, 'R');
    utl_file.get_line(input_file, input_buffer);
    --debug
    --dbms_output.put_line(input_buffer);
    utl_file.fclose(input_file);
    --return data
    return input_buffer;
    end;
    Hope this helps.

  • Why there is a huge difference between a row size on a disk based table and a row size in memoptimized table of SQL 2014?

    Hi All,
    I have two table with similar structure and data, one is on disk and the other is in memory. I somehow calculated the difference between a row size of on disk and in memory table and found that the row size of in memory is 700 Bytes more than the disk based
    tables.
    aa

    As others mentioned, memory optimized tables and disk based tables have different structures in SQL Server 2014.
    For memory optimized tables, the number of indexes on table also contribute to the size. You can calculate the exact size of rows and thus the table size using the formula given in the below articles
    Table and Row Size in Memory-Optimized Tables
    Estimate the Size of a Table
    Krishnakumar S

  • Tables and Joins used in constructing SQL

    I am new to OBIEE. I contructed my physical layer table joins etc.
    In my logical layer I have a source that is using a few physical tables. I have defined the joins (some right outer etc.). I go into Answers to display some info. When I examine my SQL source in NQQuery.log I see tables being used that I have not defined in my source. It is picking some from my other Logical tables. Why is that? Is it from the way I joined things in the Business Model?

    Double post:
    Outer Joins with multiple columns
    The two post are similar. You have first to understand the logic of OBIEE.
    And first which table is your fact table ?
    http://gerardnico.com/wiki/dat/obiee/bi_server/design/fact_table/obiee_identifying_fact_table
    Cheers
    Nico

  • SSIS - Script Task creates a DTS var and using Foreach loop, Execute SQL needs to INSERT into table from this DTS var.

    I have a script task written in C# that creates an array of strings "arrayFields" after parsing a text file. It saves the array of strings in a DTS variable.
    Each row in array represents a row is comma separated and is a row that must be inserted into a table. For example,
    X and Z are fields in the table
    X1, X2,....Xn
    Z1,Z2,...Zn
    I am using a Foreach Loop  to grab each row and then  Execute SQL Task to take each row from the array and insert each field per row in a table,
    The SQL is something like,
    INSERT dbo.table values(field1, field2,...fieldn) arrayFields?
    What should this this INSERT look like?

    I guess you implemented
    Shredding a Recordset
    Based on what I understood (correct me if I am wrong) you have difficulties mapping the input parameters, if so here is the guide
    http://www.sqlis.com/sqlis/post/The-Execute-SQL-Task.aspx
    In short it might look like
    INSERT dbo.table  (ColumnA, ColumnB,...) VALUES (?,?...)
    The syntax for the T-SQL INSERT is http://technet.microsoft.com/en-us/library/dd776381%28v=sql.105%29.aspx
    Arthur
    MyBlog
    Twitter

  • Write the DDL to construct the Facebook User and Post tables in SQL server.

    Write the DDL to construct the Facebook User and Post tables in SQL server. You need to populate the user table with the user’s information provided as in Figure 1 and additional attributes may be needed for the design. Use the ID in the excel file to
    identify the other Facebook user. For example ID 612831408762037 is David Cunliffe. Import the excel sheets to SQL server and then write effective SQL to merge the two tables into the Post table. Ensure the relationship is maintained between entities. Submit
    the SQL scripts that create the database and tables, import the excel sheets and populate the tables such that one can re-create the database and tables with all the data by running the script.

    IF NOT EXISTS(SELECT * FROM sys.databases WHERE name = N'xxx')
    CREATE DATABASE xxx
    GO
    USE xxx
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'DAVID') 
    DROP TABLE DAVID;
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'JOHN')
    DROP TABLE JOHN;
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'NEWDAVID') 
    DROP TABLE NEWDAVID;
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'NEWJOHN') 
    DROP TABLE NEWJOHN;
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'USER') 
    DROP TABLE [USER];
    IF EXISTS(SELECT * FROM sys.tables WHERE name = N'POST') 
    DROP TABLE POST;
    CREATE TABLE DAVID(
    ID VARCHAR(100),
    [MESSAGE] VARCHAR(MAX),
    [TYPE] VARCHAR(MAX),
    CREATED_TIME VARCHAR(MAX),
    UPDATED_TIME VARCHAR(MAX),
    SHARES_COUNT VARCHAR(MAX),
    [COUNT OF LIKES NAME] VARCHAR(MAX),
    [COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
    LINK VARCHAR(MAX),
    NAME VARCHAR(MAX),
    [DESCRIPTION] VARCHAR(MAX),
    CREATE TABLE JOHN(
    ID VARCHAR(100),
    LINK VARCHAR(MAX),
    NAME VARCHAR(MAX),
    [DESCRIPTION] VARCHAR(MAX),
    [TYPE] VARCHAR(MAX),
    CREATED_TIME VARCHAR(MAX),
    UPDATED_TIME VARCHAR(MAX),
    [COUNT OF LIKES NAME] VARCHAR(MAX),
    [COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
    [MESSAGE] VARCHAR(MAX),
    SHARES_COUNT VARCHAR(MAX),
    EXECUTE (N'BULK INSERT DAVID FROM ''' + 'datapath' + N'david.csv''
    WITH (
        CHECK_CONSTRAINTS,
        CODEPAGE=''ACP'',
        DATAFILETYPE = ''char'',
        FIELDTERMINATOR= '','',
        ROWTERMINATOR = ''\n'',
        KEEPIDENTITY,
        TABLOCK
    EXECUTE (N'BULK INSERT JOHN FROM ''' + 'datapath' + N'john.csv''
    WITH (
        CHECK_CONSTRAINTS,
        CODEPAGE=''ACP'',
        DATAFILETYPE = ''char'',
        FIELDTERMINATOR= '','',
        ROWTERMINATOR = ''\n'',
        KEEPIDENTITY,
        TABLOCK
    SELECT * FROM DAVID
    SELECT * FROM JOHN
    CREATE TABLE NEWDAVID(
    POST_ID VARCHAR(100),
    [USER_ID] VARCHAR(100),
    CREATED_DATE VARCHAR(MAX),
    CREATED_YEAR VARCHAR(MAX),
    CREATED_MONTH VARCHAR(MAX),
    UPDATED_DATE VARCHAR(MAX),
    UPDATED_YAER VARCHAR(MAX),
    UPDATED_MONTH VARCHAR(MAX),
    [MESSAGE] VARCHAR(MAX),
    SHARES_COUNT VARCHAR(MAX),
    [COUNT OF LIKES NAME] VARCHAR(MAX),
    [COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
    NAME VARCHAR(MAX),
    [TYPE] VARCHAR(MAX),
    LINK VARCHAR(MAX),
    [DESCRIPTION] VARCHAR(MAX),
    CREATE TABLE NEWJOHN(
    POST_ID VARCHAR(100),
    [USER_ID] VARCHAR(100),
    CREATED_DATE VARCHAR(MAX),
    CREATED_YEAR VARCHAR(MAX),
    CREATED_MONTH VARCHAR(MAX),
    UPDATED_DATE VARCHAR(MAX),
    UPDATED_YAER VARCHAR(MAX),
    UPDATED_MONTH VARCHAR(MAX),
    [MESSAGE] VARCHAR(MAX),
    SHARES_COUNT VARCHAR(MAX),
    [COUNT OF LIKES NAME] VARCHAR(MAX),
    [COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
    NAME VARCHAR(MAX),
    [TYPE] VARCHAR(MAX),
    LINK VARCHAR(MAX),
    [DESCRIPTION] VARCHAR(MAX),
    INSERT INTO NEWJOHN
    SELECT SUBSTRING(ID, CHARINDEX('_', ID) + 1, LEN(ID) - CHARINDEX('_', ID)) AS POST_ID, 
      SUBSTRING(ID, 1, CHARINDEX('_', ID) -1) AS [USER_ID], 
      SUBSTRING(CREATED_TIME, 1, 10) AS CREATED_DATE,
      SUBSTRING(CREATED_TIME, 1, 4) AS CREATED_YEAR,
      SUBSTRING(CREATED_TIME, 6, 2) AS CREATED_MONTH,
      SUBSTRING(UPDATED_TIME, 1, 10) AS UPDATED_DATE,
      SUBSTRING(UPDATED_TIME, 1, 4) AS UPDATED_YEAR,
      SUBSTRING(UPDATED_TIME, 6, 2) AS UPDATED_MONTH,
      [MESSAGE], SHARES_COUNT, [COUNT OF LIKES NAME], [COUNT OF COMMENTS MESSAGE], NAME, [TYPE], LINK, [DESCRIPTION]
    FROM JOHN
    INSERT INTO NEWDAVID
    SELECT SUBSTRING(ID, CHARINDEX('_', ID) + 1, LEN(ID) - CHARINDEX('_', ID)) AS POST_ID, 
           SUBSTRING(ID, 1, CHARINDEX('_', ID) -1) AS [USER_ID], 
      SUBSTRING(CREATED_TIME, 1, 10) AS CREATED_DATE,
      SUBSTRING(CREATED_TIME, 1, 4) AS CREATED_YEAR,
      SUBSTRING(CREATED_TIME, 6, 2) AS CREATED_MONTH,
      SUBSTRING(UPDATED_TIME, 1, 10) AS UPDATED_DATE,
      SUBSTRING(UPDATED_TIME, 1, 4) AS UPDATED_YEAR,
      SUBSTRING(UPDATED_TIME, 6, 2) AS UPDATED_MONTH,
      [MESSAGE], SHARES_COUNT, [COUNT OF LIKES NAME], [COUNT OF COMMENTS MESSAGE], NAME, [TYPE], LINK, [DESCRIPTION]
    FROM DAVID
    SELECT * FROM NEWDAVID
    SELECT * FROM NEWJOHN
    CREATE TABLE POST (
    POST_ID VARCHAR(100) NOT NULL,
    [USER_ID] VARCHAR(100),
    CREATED_DATE VARCHAR(MAX),
    CREATED_YEAR VARCHAR(MAX),
    CREATED_MONTH VARCHAR(MAX),
    UPDATED_DATE VARCHAR(MAX),
    UPDATED_YAER VARCHAR(MAX),
    UPDATED_MONTH VARCHAR(MAX),
    [MESSAGE] VARCHAR(MAX),
    SHARES_COUNT VARCHAR(MAX),
    [COUNT OF LIKES NAME] VARCHAR(MAX),
    [COUNT OF COMMENTS MESSAGE] VARCHAR(MAX),
    NAME VARCHAR(MAX),
    [TYPE] VARCHAR(MAX),
    LINK VARCHAR(MAX),
    [DESCRIPTION] VARCHAR(MAX),
    INSERT INTO POST
    SELECT * FROM NEWDAVID UNION SELECT * FROM NEWJOHN
    SELECT * FROM POST 
    CREATE TABLE [USER] 
    [USER_ID] VARCHAR(100) NOT NULL,
    INSERT INTO [USER] VALUES (612831408762037),(1119736203) 
    ALTER TABLE [USER] ADD PRIMARY KEY([USER_ID])
    ALTER TABLE POST ADD PRIMARY KEY(POST_ID) 
    ALTER TABLE POST ADD FOREIGN KEY([USER_ID]) REFERENCES [USER]([USER_ID])

Maybe you are looking for

  • Spotlight indexing of Time Capsule - feature or bug?

    I understand why backups are indexed: the ability to use Spotlight from within Time Machine is a fantastic feature.  But the method by which this index is created does not make sense where a Time Capsule is in use (or indeed most networked storage, b

  • Element 11trial version photo editor not opening

    I have the main screen pop up and asks if I want to organize my pictures or edit them.  Nothing happens when I clock edit.  Then I go into the organize and try to go to edit and an error message comes up saying I need the trial to dowload to use this

  • Can't get this to traverse

    I'm trying to just traverse a linked list, putting each data into a new list. I can't get it to just traverse and not empty the first list. I tried putting the ListNode current = firstNode; somewhere where it wouldn't reset every time the method getF

  • What is the best upgrade. If I am using PM 6.5

    Hello Everyone,                       We create E-books nothing to do with designing and some time (Maths-Equations). Currently, We using PM 6.5 on win:98 with all that old software installed. However, We looking for upgrade either Win7 or Win-Xp. I

  • Can Apple add a French song to US iTunes store?

    When traveling in France, we heard the song Nouveaux Horizons by Melissa NKonda. We knew our daughter would LOVE it. We found the video on YouTube, and she does LOVE the song. Now, we want to buy it via iTunes. Can it be added to the US store? I can'