Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

Ralph D Wilson II

@Ralph D Wilson II
About
Posts
6
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Select statement: ordering by column name.
    R Ralph D Wilson II

    Did that wok for you?

    Database database xml question

  • Select statement: ordering by column name.
    R Ralph D Wilson II

    Th following could be implemented as a Sotred Procedure or simply executed as is in a query:

    USE {enter your desired database name here};

    DECLARE @NameOfTable VarChar(128);
    SET @NameOfTable = '{enter your desired table name here}';

    DECLARE @SQLStatement VarChar(8000);

    SET @SQLStatement = 'SELECT ''' + @NameOfTable + ''' AS TableName';

    PRINT @SQLStatement;

    EXEC(@SQLStatement);

    WITH TableColumns_CTE
    AS
    (
    SELECT T.name AS TableName
    ,C.name AS ColumnName
    ,ROW_NUMBER() OVER (PARTITION BY T.name ORDER BY T.name, C.name) Seq
    FROM sys.tables T
    INNER JOIN sys.columns C
    ON T.object_id = C.object_id
    AND T.name = @NameOfTable
    )

    SELECT @SQLStatement = @SQLStatement + ', ' + ColumnName
    FROM TableColumns_CTE;

    SELECT @SQLStatement = @SQLStatement + ' FROM ' + @NameOfTable + ';';

    PRINT @SQLStatement;

    EXEC(@SQLStatement);

    Database database xml question

  • Inserting Master and DEtail Tables
    R Ralph D Wilson II

    Abdul, My questions here are: 1. Can I write logic in SSIS to update if the record already exists and certains columns are same, if so how can I do that. 2. If I incorporate logic into SSIS, can the performance be same as simple import process. Because the simple import process in SSIS uses the bulk insert mechanism with batch inserts of records. The answer to your question isn't as simple as you may think. In the first place, your use of the phrase "can I" adds to the problem because it seems that you are very much an SSIS novice. so let me approach this in anothe way. 1. An SSIS package can be created that would handle your problem. The trick is to use the MERGE statement that is available in T-SQL. You can also use a pair of SQL statements such as those that you provided in your most recent post. Howver, your SQL code may be impacting our performance somewhat because you are using the IN (SELECT....) instead of using the INNER JOIN approach to determining which rows to update. 2. A straight forward bulk load is always going to be the fastest choice; however, since you need to UPDATE some rows and INSERT others, that option isn't available to you,so there's no point in worrying about that. ;-) That being said, though, if this is your first SSIS package, I would suggest that you create a temp table into which you the INSERT both updated versions of the existing rows and then the new rows (with the IDENTITY INSERT ON, so that you can keep the IDs of the existing rows), and then truncate the existing table and reload it from the temp table. ;-)

    Database database help sql-server sysadmin algorithms

  • Select statement: ordering by column name.
    R Ralph D Wilson II

    Maybe I missed something in reading through the thread but I'll ask anyway. ;-) What RDBMS are you using? If it is SQL Server (or probably most others) you can create a query that will generate a SELECT statement from the table and column information in the system tables (in SQL Server, sys.tables and sys.columns). Once that is generated (and a DECLAREd variable set to that varchar string, you can execute the r results.

    Database database xml question

  • SQL Server 2012 - forming relationship between tables
    R Ralph D Wilson II

    To somewhat piggy-back on the previous suggestions, I would recommend that you consider using an Identity column for your Primary Key and then using the PK to accomplish the links beween tables. For Example: Table: Buildings BuildingID [int] Primary Key Identity (1-1) BuildingName [VarChar] (25) ... Table: BuildingRooms BuildingRoomID [int] Primary Key Identity (1-1) BuildingID INT RoomName [Varchar] (10) ... Table: Assets AssetID [int] Primary Key Identity (1-1) AssetNumber [varchar] (25) AssetName [VarChar] (50) BuildingRoomID [int] ... By using using the Identity columns for the PK's of the tables, you can make your joins much more easily. You may also want to add some Unique Indexes on, for instance, the BuildingName, RoomName, and AssetNumber columns just to make sure someone doesn't accidentally add those items multiple times. ;-) Check out the following link regarding what is termed "normalization" . . . which is what we have suggested with regard to your tables. ;-) http://www.dbnormalization.com/rules-of-normalization-i

    Database database question sql-server sysadmin

  • First language
    R Ralph D Wilson II

    First spoken language: Japanese First Computer Language: JCL (Vintage 1969 ;-) I don't use either on a regular basis. However, I have found Japanese (and German, which I learned late) to be handy for variable names and labels (especially in Assembly language programming).

    The Lounge question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups