Reading table of SQL server

Hi,
i want to read a table from SQL server, outside of sap.
How can i do that, without database connection?
I want to do it through webservice but i do not know how to do.
Answers will be appreciated immediately.
Thanks.

Hi Sandra,
Thank you for the response.
I could able to fetch the document related data by using the FM 'BAPI_DOUMENT_GETDETAIL2' and it is working fine but not returning the file content into an internal table. Today I even able to  find a function module 'SDOK_PHIO_LOAD_CONTENT' to load the file content into binary.
Now, the problem is  to create an attachment to the quality manangement tab of material master. I could able to add a subscreen to it and trying to display the file(s) as an attachment(s).
I have tried 'SDOK_PHIO_CREATE' , 'SO_ATTACHMENT_INSERT_API1' (not for mail attachment)etc. function modules but couldn't able to find the soultion. I also got a file namely 'CA-PLM u2013 Product Lifecycle Management Functional Overview' which talks ablout the DMS Management. But the function modules specified in this doc from SAP AG are used for Document info record manipulations but not the attachments assigned to them.
So, I request you to let me know some FMs which can be used to achieve this attachment creation requirement.
Thank You,
Regards,
Naresh.

Similar Messages

  • Read Oracle 10g Tables to SQL Server 2012

    Hi all,
    I have Oracle 10g on an XP machine, and use the 'Oracle in OraDB10g_home1' driver to read the data. I have another Windows Server 2008 R2 machine on the same network, with SQL Server 2012 on it. What is the best way to read Oracle Tables in SQL Server? Can I setup an ODBC link from my Windows Server machine to the Oracle Database (which would require me to download an Oracle ODBC driver)? Or is the best way to export the required tables from Oracle (e.g. into csv format) and import them into SQL?
    Thanking you in advance,
    Imelda.

    987575 wrote:
    Hi all,
    I have Oracle 10g on an XP machine, and use the 'Oracle in OraDB10g_home1' driver to read the data. I have another Windows Server 2008 R2 machine on the same network, with SQL Server 2012 on it. What is the best way to read Oracle Tables in SQL Server? Can I setup an ODBC link from my Windows Server machine to the Oracle Database (which would require me to download an Oracle ODBC driver)? Or is the best way to export the required tables from Oracle (e.g. into csv format) and import them into SQL?
    Thanking you in advance,
    Imelda.You should use Heterogeneous Services
    Following is a demonstration in ASKTOM to connect from Oracle to Excel, You can use the same to connect to SQL Server.
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:4406709207206#18830681837358

  • Table or Object type - like #temp table in SQL Server

    Hi
    I need to create a temp table to hold certain data and then validate. What is the best way to do this oracle. Something similar to #temp tables in SQL Server.
    Thanks

    IN Oracle, you create the temporary table once, before you start your program. Then anyone can use that definition, but the system keeps the data isolated to eachr/session.
    The difference in using Oracle: all DDL, including creating temp tables, performs commits and aquires locks that you want to avoid. It creates unnecessary serialization, causes transactional consistency issues and puts Oracle's Read Consistent model at risk (of ORA-01555 errors).
    So, you (or the DBA) would "CREATE GLOBAL TEMPORARY TABLE ..." with the appropriate definition you want, and indicate whether you want the data deleted on commit, or on logoff.
    Then you write your procedure, similar to the way you would do it in SQL Server, but you would not bracket it with creating/dropping the temp table - no need.

  • Group by languages in multilingual table in sql server

    Hi ,
    I am having a multilingual table in SQL server 2008 , the table has two columns ID and Text
    The text column has English, Chinese and other language texts.
    I need a resultset grouped by the languages and count of id like
    Language   count_of_id
    English          25
    Chinese         10
    other languages 3
    Is this possible? Can you please help me?

    Good day SqlServer_learn
    I have a saying that I always uses: anything is possible in developing, if you have the appropriate resources (change the existing solution could be part of the way to solve...)
    regarding your question, there is simple solution, but for most cases, I highly recommend to change the table structure and add a column for the culture of the text (like: en-us for english,
    he-il for Hebrew and so on..).
    Since you are using unicode column like nvarchar to store multi language text,
    we can get the language from the text itself, as long as it include characters from that language (text which include only numbers for example we we consider as default language since it is the same in all languages). 
    step 1: First you need an accessory table (Named like UnicodeMapping) which include all unicode characters and the number of the char in unicode (a mapping unicode table). You can use ranges as well, but
    it will be faster for the queries if you actually have all the characters, and not just range.
    For example this table (I added English and Hebrew... Do the same with all the languages that you need):
    create table UnicodeMapping (Charecter nchar(1), UnicodeNum int, CultureN NVARCHAR(100), CollateN NVARCHAR(100))
    GO
    -- fill the table with main Hebrew characters, using a number table
    insert UnicodeMapping (Charecter, UnicodeNum, CultureN, CollateN)
    select NCHAR(n), n, 'He-IL', 'Hebrew_CI_AS'
    from _ArielyAccessoriesDatabase.dbo.ArielyNumbers
    where
    n between 1488 and 1514 -- Hebrew
    or n between 64304 and 64330 -- Hebrew
    GO
    -- fill the table with main English characters, using a number table
    insert UnicodeMapping (Charecter, UnicodeNum, CultureN, CollateN)
    select NCHAR(n), n, 'En-US', 'SQL_Latin1_General_CP1_CI_AS'
    from _ArielyAccessoriesDatabase.dbo.ArielyNumbers
    where
    n between 97 and 122 -- En
    or n between 65 and 90 -- En
    GO
    -- Do the same with all the languages that you need, and all the UNICODE ranges for those languages
    select * from UnicodeMapping
    GO
    Step 2: You can create a function which get NVARCHAR as input and return the culture as output, or work directly on the data using JOIN your table and this table.
    Assuming that each row is in specific language, In order to recognize the language, you just need to check 1 character from the original string (a text character and not a number for example which might be in any language) and examine which language this
    single character is, using the our UnicodeMapping.
    You can check this thread to see an implementation of this idea: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ccc1d16f-926f-46c8-8579-b2eecf661e7c/sort-miultiple-language-data-in-sql-serevr-by-collation?forum=transactsql
    * dont forget to add to the table all the characters like numbers and chose them as your default language
    * in the link above I just select the first character using LEFT, but if the text start with number for example then you will get default language. If you sure that the text must start with real language character then it is best solution, but if not, than
    It is better to use a "user defined function" which will find the first character that is not in the default language. if the function do not find any char in non-default language than it return default language, else it check the language using
    the UnicodeMapping and return it.
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Problem loading table in SQL server

    Hi,
    I'm trying to load a table in SQL server from another instance of SQL server.
    I have defined the physical and and logical data stores and reverse engineered the models to retrieve the tables.
    The target table was created manually..
    If I try to run the interface i get the fololowing error
    ODI-1227: Task SrcSet0 (Loading) fails on the source MICROSOFT_SQL_SERVER connection DATAWAREHOUSE.
    Caused By: java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver][SQLServer]Incorrect syntax near '<'.
    at weblogic.jdbc.sqlserverbase.ddb_.b(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddb_.a(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddb9.b(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
    at weblogic.jdbc.sqlserver.tds.ddr.v(Unknown Source)
    at weblogic.jdbc.sqlserver.tds.ddr.a(Unknown Source)
    at weblogic.jdbc.sqlserver.tds.ddq.a(Unknown Source)
    at weblogic.jdbc.sqlserver.tds.ddr.a(Unknown Source)
    at weblogic.jdbc.sqlserver.ddj.m(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddel.e(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddel.a(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddde.a(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddel.v(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddel.r(Unknown Source)
    at weblogic.jdbc.sqlserverbase.ddde.execute(Unknown Source)
    at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2913)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2625)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:558)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:464)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2093)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:366)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:292)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:855)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
    at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:662)
    It is trying to run the following SQl and I'm not sure why it is trying to drop and create a view in the source system ? The interface that I'm running above has just a source to target mapping..
    drop view <Undefined>.SQLDATAWH_DATAWAREHOUSEAccountDim
    Any pointers will be helpful..
    Thanks in advance...

    whirlpool wrote:
    I think I selected MSSQL one.. but I donot have access to the server now..Is this the correct KM ?
    If you have selected IKM MSSQL Incremental Update then it is the correct IKM to choose.
    To use this IKM, the staging area must be on the same data server as the target.
    What is the LKM selected ?
    I right clicked on the Reverse-Engineering (RKM) models and imported all knowledge modules.. Is that how its done ?
    It is fine.
    is that the correct one...I donot understand why the interface is trying to drop and create a view in source system..
    It depends on the KM selected . So first get the name of LKM and IKM used in interface.

  • 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; 

  • How to Create a Temporary Table with SQL Server

    I know you can create a temporary table in SQL Server 2000, but not quite sure how to do it in CFMX 7, i.e., does the SQL go inside a <CFQUERY dbtype="query"> tag?
    I'm pulling the main set of records from an Oracle server (1st data source), but it does not contain employee names, only employee IDs.  Since I need to show the employee name along with the Emp ID, I'm then pulling a list of "current" employee names from a SQL Server (2nd data source), which is the main database on our CF server.
    I've got a QofQ that works fine, except it only matches EmpIDs that exist in both result sets.  Employees who are no longer employed, don't match, and don't display.  Since I can't do a LEFT OUTER JOIN with a QofQ, what I need to do is get the records from the Oracle server into the SQL Server.  Preferably in a temporary table.
    I was hoping if I could get those Oracle records written to a temp table on the main SQL Server, in same database as the Employee Name table, I could then write a normal <CFQUERY> that uses a LEFT OUTER JOIN.
    I think I could probably write a Stored Procedure that would execute the SQL to create the temporary table, but am trying to avoid having to write the SP, and do it the simplest way.
    This query will be a program that can be run hundreds of times per day, with a form that allows users to select date ranges, locations, and other options.  That starts the queries, which creates the report.  So I just need the temp table to exist only until all the SQL has run, and the <CFOUTPUT> has generated a report.
    If the premise is right, I just need some help with the syntax for creating a SQL Server temp table, when you want to write records to it from an external data source.  I'm trying the following, but getting an error:
    <CFQUERY name="ITE_Temp" datasource="SkynetSQL">
    CREATE TABLE #MyTemp
    (   INSERT INTO #MyTemp
    ITE2.TrueFile char (7) NOT NULL,
    ITE2.CountOfEmployee int NULL,
    ITE2.DTL_SUBTOT decimal NULL,
    ITE2.EMPTYPE char (3) NULL,
    ITE2.ARPT_CD char (3) NULL
    </CFQUERY>
    So I actually created a permanent table on the SQL Server, and wrote the below SQL, which does work, and does write the records to table.  I can then write another CFQUERY with a LEFT OUTER JOIN, and get all the records, including those that don't have matching employee name:
    <CFQUERY datasource="SkynetSQL">
    <CFLOOP index="i" from="1" to = "#ITE2.RecordCount#">
    INSERT INTO ITE_Temp
       (FullFile,
       EmployeeCount,
       DTL_Amount,
       EmployeeType,
       station)
    VALUES  ('#ITE2.TrueFile[i]#',
       #ITE2.CountOfEmployee[i]#,
       #ITE2.DTL_SUBTOT[i]#,
       '#ITE2.EMPTYPE[i]#',
       '#ITE2.ARPT_CD[i]#')
    </CFLOOP>
    </CFQUERY>
    But, I hate to have to create a table and physically write to it.  For one, it seems slower, and doing it in temp would be in memory, and probably much faster, correct?  Is there some way to code the above, so that it does something similar, but in a TEMPORARY TABLE?   If I can figure out how to do this, I can pull data from multiple data sources and servers, and using SQL Server temp tables, work with the data as if it was all on the same SQL Server, and do some cool reports.
    Everything I've done for the past few years, has all been from data from a single source, whether SQL Server, or another server.  Now I need to start writing reports where data can come from 3 or 4 different servers, and be able to do joins (inner and outer).  Thanks for any advice/help.  Much appreciated.
    Gary

    While waiting to hear back, I was able to write the query results from an outside Oracle server, to a table on the local SQL Server, and do the LEFT OUTER JOIN required for the final query and report to work.  That was with this syntax:
    <CFQUERY name="AddTableRecords" datasource="MyTable">
    TRUNCATE TABLE ITE_Temp
    <CFOUTPUT query="ITE2">
    INSERT INTO ITE_Temp
    (FullFile,EmployeeCount,DTL_Amount,EmployeeType,station)
    VALUES
    ('#TrueFile#', #CountOfEmployee#, #DTL_SUBTOT#, '#EMPTYPE#', '#ARPT_CD#')
    </CFOUTPUT>
    </CFQUERY>
    However, I was not able to write to a temporary table AND read the results. I got the syntax to run to write the above results to a temporary table.  But when I tried to read and output the results from the temp table, I got an error.  Also, it wouldn't take the single "#" (local) only the global "##" table var, using this syntax.  Note that if I didn't have the DROP TABLE in the beginning, the 2nd time you run this query, you get an error telling you the table already exists.
    <CFQUERY name="ITE_Temp2" datasource="MyTable">
    DROP TABLE ##MyTemp2
    CREATE TABLE ##MyTemp2
    FullFile char (7) NOT NULL,
    EmployeeCount int NULL,
    DTL_Amount decimal NULL,
    EmployeeType char (3) NULL,
    station char (3) NULL
    <CFOUTPUT query="ITE2">
    INSERT INTO ##MyTemp2 VALUES
    '#ITE2.TrueFile#',
    #ITE2.CountOfEmployee#,
    #ITE2.DTL_SUBTOT#,
    '#ITE2.EMPTYPE#',
    '#ITE2.ARPT_CD#'
    </CFOUTPUT>
    </CFQUERY>
    So even though the above works, I could use some help in reading/writing the output.  I've tried several things similar to below, but they don't work.  It't telling me ITE_Temp2 does not exist.  It's not easy to find good examples of creating temporary tables in SQL Server.
    <CFQUERY name="QueryTest2" datasource="SkynetSQL">
    SELECT *
    FROM ITE_Temp2
    </CFQUERY>
    <CFOUTPUT query="ITE_Temp2">
    Output from Temp Table<br>
    <p>FullFile: #FullFile#, EmployeeCount: #EmployeeCount#</p>
    </CFOUTPUT>
    Thanks for any help/advice.
    Gary.

  • How to use create-default-dbms-tables in SQL Server 2000

    Hi everyone,
    I'm new in EJB development. I'm trying to deploy a CMP to Weblogic 8.1 SP1 using
    JBuilderX. I configured a ConnectionPool and DataSource to allow the CMP to access
    the SQL Server 2000. However, I cannot deploy the CMP if I didn't create the table
    in SQL Server manually. Does anyone know how to use the create-default-dbms-tables?

    Refer to
    http://e-docs.bea.com/wls/docs81/ejb/DDreference-cmp-jar.html#1162249
    "Keith" <[email protected]> wrote:
    >
    Hi everyone,
    I'm new in EJB development. I'm trying to deploy a CMP to Weblogic 8.1
    SP1 using
    JBuilderX. I configured a ConnectionPool and DataSource to allow the
    CMP to access
    the SQL Server 2000. However, I cannot deploy the CMP if I didn't create
    the table
    in SQL Server manually. Does anyone know how to use the create-default-dbms-tables?

  • Import MS Access 2013 tables into SQL Server 2012

    Hi there,
    Is there a step by step example somewhere showing how to import an MS Access 2013 table into SQL Server 2012?
    I have read the existing posts and don't see a definitive answer.
    I have installed MS Access 2010 engine, first 32 bit then 64 bit.
    I have installed the MS Access 2013 runtime on my server.
    I use the Office 2015 Access Database Engine OLE DB Provider.
    I get the error:
    Error 0xc0202009: Source - APEntries [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
    Error 0xc02020e8: Source - APEntries [1]: Opening a rowset for "`TableName`" failed. Check that the object exists in the database.
    The post regarding the above errors doesn't resolve the issue.
    I have full administrative permissions on the server.
    What is the trick to making this work?
    Thanks,
    Ric
    Ric Miller

    Hi there,
    I tried the exact same operation on a third machine.
    This machine has Windows 8.1 64 bit, SQL Server 2012 64 bit, MS Office 2013 Plus 32 bit.
    I am the administrator on this machine.
    I installed this:
    Microsoft Access Database Engine 2010 Redistributable 32 bit (because I have MS Office 2013 plus 32 bit installed.)
    From here:
    http://www.microsoft.com/en-us/download/details.aspx?id=13255
    It won't let me install the 64 bit version without uninstalling MS Office 32 bit.
    I created an MS Access database on this machine using MS Access 2013 and created a table with 3 records.
    I used the "Import and Export Data (32 bit)" from the start menu.
    After I installed the "Database Engine 2010 32 bit" driver above, I now have the option of "Office 2015 Access Database Engine OLE DB Provider" as Data Source which I did not have prior to doing this installation.
    I selected the driver and added the Properties of the Data Source Name file location of the MS Access file. I am using a blank password.
    I go thru the same sequence of selecting a table to import and after running the result is the same:
    Error 0xc0202009: Source - APEntries [1]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E37.
    "Error 0xc02020e8: Source - APEntries [1]: Opening a rowset for "`TableName`" failed. Check that the object exists in the database."
    This seems to be consistent across three machines with three operating systems with the same files and the same result.
    I understand that some people have gotten this to work.
    I would appreciate it if anyone can report an error in the above procedure to me.
    Thanks,
    Ric
    Ric Miller

  • Migration of table from sql server to oracle

    Hi,
    I had to export few tables from SQL Server to Oracle. After the migration, I am checking to see all the tables in Oracle that have been migrated from Sql Server. I am executing select * from tab; and am seeing all the the tables (including those have been exported) from the output list of tables. However, when I am doing a select * from x; where x is one of the few tables that have been migrated, it says table or view does not exist. This is the problem with all other migrated tables. Any help is appreciated in advance. Thanks.
    [email protected]

    Try select * from "x"

  • Reading BLOB from SQL Server 2005 using DB Link from Oracle 10g

    Hi All,
    I am trying to read a table's data from SQL Server 2005 using ODBC DB Link created in Oracle 10g (10.2.0.3/4) database. I am not using oracle gateway.
    I am able read all data except for the BLOB data from SQL server 2005. It gives error given below when I try to execute query SELECT * from T_TRANSACTION_DATA@sdeslink inside a stored procedure:
    ORA-22992: cannot use LOB locators selected from remote tables
    Kindly help how to read BLOB from SQL server 2005 inside Oracle 10g.
    Best Regards!
    Irfan

    Irfan,
    If you can read the blob data using 10.2 HSODBC then there should be no problem using the 11g gateway.
    I recommend you download the latest version which is 11.2.0.3 available from My oracle Support as -
    Patch 10404530: 11.2.0.3.0 PATCH SET FOR ORACLE DATABASE SERVER
    This is a full version and does not need a previous version to have bene installed. When installing it needs to be in a completlely separate ORACLE_HOME from the existing 11.2 install.
    For the Ora-22992 problem have a look at this note in My Oracle Support -
    Ora-22992 has a workaround in 10gR2 (Doc ID 436707.1)
    Regards,
    Mike

  • Access Tables in SQL Server

    I was told that SAP on SQL Server maintains a very unique security where someone can not just directly access tables in SQL Server. I was told you need the SAP client in order to access the data stored within the DB. With other systems, normally users such as a DBA  or privileged users would be able to directly log into the database and possibly alter data, whereas this is not the case for SAP on SQL. Can someone help confirm if this is true or not and explain to me how this works.

    Hi Julia:
    You can access data stored in SQL tables using Enterprise Manager or SQL Query Analyzer and you can do in every other database system such as DB2, Informix or Oracle; there are some well-known Cluster tables that information can only be read from inside SAP.
    Regards,
    Federico

  • Create oracle table from sql server

    Dear Gurus,
    I need to create some tables from sql server 2008 to a oracle 11g database. Some tables contain vbinary datatype. Now my queries are
    1. How can I do that?
    2. If DB link is a solution then would you please provide me a step by step process to do so?
    3. Is there any issue with datatype?
    SQL Server db is on windows 2008 R2
    Oracle is in RHEL 5.5
    Will appreciate ur help.

    well suppose i generate flat files from sql server and load in oracle by sqlloader then will there be any issue with vbinary datatype? what should be the equivalent data type in oracle table?

  • How to provide joins between oracle tables and sql server tables

    Hi,
    I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server.
    how to provide joins between oracle tables and sql server tables ? Any help on this
    Regards,
    Malli

    user10675696 wrote:
    I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server. Bad idea most times. Heterogeneous joins do not exactly scale and performance can be severely degraded by network speed and b/w availability. And there is nothing you can do in the application and database layers to address performance issue at the network level in this case - your code's performance is simply at the mercy of network performance. With a single glaring fact - network performance is continually degrading. All the time. Always. Until it is upgraded. When the performance degradation starts all over again.
    If the tables are not small (few 1000 rows each) and row volumes static, I would not consider doing a heterogeneous join. Instead I would rather go for a materialised view on the Oracle side, use a proper table and index structure, and do a local database join.

  • 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

  • Connect iMac to Smart TV

    We have a big presentation in the new year and are buying a smart tv to connect to a 27" iMac. Our designer will be making changes to designs in Illustrator that we want the clients to view on the smart TV. What's the best way of linking the two plea

  • What is the best way to get PATHS from one Photoshop psd file to another?

    Hi! New on the site, and I signed up specifically to ask the best way to import one .psd file into another, including the paths on the paths palette. Almost all of my Photoshop drawings make heavy use of vector paths, which I then stroke using using

  • Batch Capture stopping early

    For some reason I set clips to batch capture and FCP 4.5 stops capturing minutes early. I already went through the QT & pro apps update fiasco and downgraded to the older formats. I've been capturing easily from analog but keep having this niggling l

  • Oracle 9i (prsonal edition) - free CD?

    Hi, I would like to know if it is possible to get oracle 9i CD (personal edition) for free? Do they (Oracle) send it for free for evaluation purposes? It is possible to get it through downloads but it takes forever (all zip files are too big) to down

  • CC not updating to newest PS CC

    Using both the Creative Cloud menu and the adobe applications manager, both say my version of photoshop is up to date, but it is not.  I would like to install the new update announced a day or 2 ago (14.2), currently i have 14.1.2. Worked fine for th