I keep product name, id in Table1. I keep Category name, id in Table2. I keep relation between product and category (product_id, category_id) in Table3. I have added some products to the table with proper category. Work fine But for some products I did not specified any category (ie their id is not present in Table3) But now I want all such products (ie all products whose category is nothing) To be associated with category_id 10
--------------------------------------------------------------- My Original Post I have to query n table(NLRImports) using the Distinct keyword, to retrieve a set of ID numbers. ( "Select DISTINCT id_nbr from NLRImport" ).
Now i want to use those values i retrieved, to process the records in the table(NLRImports) 1 by 1. How do i use those ID no's i retrieved as Variables or parameters for my next query?? If this makes sense? ----------------------------------------------------------------
First, thanks for the response.... now here is what im trying to do. I created a simple application in delphi to import information to a table in MSSql2005. This is some of the resulting columns...
Now there will be several entries with the same id no but on different dates, so i take it dates would rather be my pkey.
Then i need to take one person's entries(i work on id_nbr) and go thru all the entries taking the earliest date and comparing all the other entries for that person to the first date and select all the dates more than 19 days after the first date and less than 91 days from first date and place it in a new table. I used cursor s and while loops to kind of get it going but i know that cursors are not really recommended use but the performance implications dont bother with this particular job.
What other ways should i be using to accomplish this?
HI, I have a view where I want to add Rundate and Prev Month Rundate as computed columns to simplify my joins and calculations. Rundate will be a select from another table that has a list of rundates for each month like this. SELECT MAX(fm_dateend) FROM dbo.tbl_FiscalMonth WHERE fm_dateend <= getdate()) AS smalldatetime) AS CurrRunDate Now, I want to add Prev Month Rundate on the basis of CurrRunDate but it does not accept CurrRunDate. The query is like this
SELECT MAX(fm_dateend) FROM dbo.tbl_FiscalMonth WHERE fm_dateend < CurrRunDate) AS smalldatetime) AS PrevMonthRunDate
Can anyone help me to work around with the alias as I dont like to put a whole bunch of code inplace of CurrRunDate(Alias).
I have 2 reports where 1 is a subreport and the other one is a main report. Can i change or refer to a control(item) in the main report depending on the value of an item in the subreport, when the subreport is being run?
I have 2 identical tables one contains current settings, the other contains all historical settings.I could create a union view to display the current values from table A and all historical values from table B, butthat would also require a Variable to hold the tblid for both select statements.
Q. Can this be done with one joined or conditional select statement?
DECLARE @tblid int = 501 SELECT 1,2,3,4,'CurrentSetting' FROM TableA ta WHERE tblid = @tblid UNION SELECT 1,2,3,4,'PreviosSetting' FROM Tableb tb WHERE tblid = @tblid
Hello, Maybe anyone have done that before? I have table where i store SOURCE_TABLE_NAME and DESTINATION_TABLE_NAME, there is about 120+ tables. i need make SSIS package which selects SOURCE_TABLE_NAME from source ole db, and loads it to DESTINATION_TABLE_NAME in destination ole db.
I made such SSIS package. set ole db source data access mode to table or view name variable. set ole db destination data access mode to table or view name variable. set to variables defoult values (names of existing tables) but when i loop table names is changed, it reports error, that can map columns, becouse in new tables is different columns.
I am relatively new to SQL and as a project I have been asked to create the SQL for a simple database to record train details. I want to implement a check constraint which will prevent data from being inserted into a table if the weight of the train is more than the maximum towing weight of the locomotive. FOr instance, I need to add the unladen weight and maximum capacity of each wagon (located in the wagon type table) and compare it against the locomotive maximum pulling weight (the locomotive class table). I have the following SQL but it will not work:
check((select SUM(fwt.unladen_weight+fwt.maximum_payload) from hauls as h,freight_wagon as fw,freight_wagon_type as fwt,train as t where h.freight_wagon_serial_number = fw.freight_wagon_serial_number and fw.freight_wagon_type = fwt.freight_wagon_type and h.train_number = t.train_number) < (select lc.maximum_towing_weight from locomotive_class as lc,locomotive as l,train as t where lc.locomotive_class = l.locomotive_class and l.locomotive_serial_number = t.locomotive_serial_number))
The hauls table is where the constraint has been placed and is the intermediary table between train and freight wagon.
I may not have explained this very well; but in short, i need to compare the sum of two values in one table against a values located in another table...At present I keep getting a message telling me the sub query cannot return more than one row.
WE have a job that loads data from an Oralce DB into our SQL Server 2000 DB twice a day. The schedule has just changed so that now there is a possibility of having my west coast users impacted when it runs at 5 PM PST and my east coast users impacted when it runs at 7 AM EST. As a workaround, I have developed a DTS package that loads the data into temp tables instead of the real tables. IE. Oracle -> XTable_temp instead of Oracle -> XTable. The load sometimes takes about an hour to an hour and a half to load, so this solution works great, but I want to then lock the table, delete it and rename the temp table to table X. The pseudo code would be:
Begin Transaction
Lock Table XTable
Drop XTable
Alter Table XTable_temp rename to XTable
Release Lock XTable
End Transaction
Create XTable_temp
I see two issues with this solution. 1) I think if I can lock XTable that the lock would be released when the table is dropped and the XTable_temp was being renamed. 2) I can't find a command to rename a table.
table2 is intially populated (basically this will serve as historical table for view); temptable and table2 will are similar except that table2 has two extra columns which are insertdt and updatedt
process: 1. get data from an existing view and insert in temptable 2. truncate/delete contents of table1 3. insert data in table1 by comparing temptable vs table2 (values that exists in temptable but not in table2 will be inserted) 4. insert data in table2 which are not yet present (comparing ID in t2 and temptable) 5. UPDATE table2 whose field/column VALUE is not equal with temptable. (meaning UNMATCHED VALUE)
* for #5 if a value from table2 (historical table) has changed compared to temptable (new result of view) this must be updated as well as the updateddt field value.
I have a table with several million rows and it gets queried every day by an application. When this happens, it either ties up the server or crashes SQL 6.5 in general. Because of the thoroughness of the query, its understandable. An idea to get around the locking up was to run DBCC CHECKTABLE on this table to put it in cache and run the query.
Will this speed up the process or prevent the locks? Has anyone done this?
Hi, I created a package to load a fact table which loads more than 7 million records. When loading the table it took nearly 15 minutes. Then indexes were created for the table at the DB level after which the time to load same number of records has increased. How to resolve this time delay?
I have delta loaded all the dimension tables now and each dimension table is related to fact table through a surrogate key, How do i further load a fact table. Please tell me I am stuck up here.. :( .
If any one has an example to refer please do tell me
I am familiar with the MySQL Load Data command to load an external ascii file into a database table, but am having trouble finding a T-Sql command that is equivalent without creating an executable...any help would be appreciated...
I've got a db table, that I created in Sever Studio Management and I can se all the data and everything the problem is that when I load it to the movile device (windows mobile 5.0) it says that the table is NotAble but in the management works fine, I can't even do a "select * from table", and if you check the query analyzer you se the table but it has no columns.
Hi I am strugglinh since last 2 days .SSIS is giving me torrid time
I am getting error while loadding the fact table
[Destination Fact Table [1099]] Error: An OLE DB error has occurred. Error code: 0x80040E21. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E21 Description: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". [Destination Fact Table [1099]] Error: The "input "OLE DB Destination Input" (1112)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (1112)" specifies failure on error. An error occurred on the specified object of the specified component. [DTS.Pipeline] Error: The ProcessInput method on component "Destination Fact Table" (1099) failed with error code 0xC0209029. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.
Please help
I have already googled for this error and appied whatever tips were given.
I need to replace all the "User Friendly Names" with "System Names" in the calculations, i.e., I need "Sales Units" to be replaced with "cSalesUnits", "AUR" replaced with "cAUR", "Comp Sales Units" with "cCompSalesUnits", and "Comp AUR" with "cCompAUR". (It isn't always as easy as removing spaces and added 'c' to the beginning of the string...)
I have created a CTE of all the "Look-up" values, and have tried all kinds of joins, and other functions to achieve this, but so far nothing has quite worked.
How can I accomplish this?
Here is some SQL for set up. There are over 500 formulas that need updating with over 400 different "look up" possibilities, so hard coding something isn't really an option.
Below is the error, Thanks!! [Data Conversion 1 [157]] Error: Data conversion failed while converting column "Media Type" (89) to column "Media Type" (201). The conversion returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".
[Data Conversion 1 [157]] Error: The "output column "Media Type" (201)" failed because truncation occurred, and the truncation row disposition on "output column "Media Type" (201)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.
[DTS.Pipeline] Error: The ProcessInput method on component "Data Conversion 1" (157) failed with error code 0xC020902A. The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.
[DTS.Pipeline] Error: The PrimeOutput method on component "Source - Test" (1) returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.
I have a Excel cross-tab (multilevel column) report that need to be loaded into a database table. Currently, I am using a Excel macro that convert the columns into rows before loading into the database table. I was thinking whether there is a better way of doing this perhaps in SSIS or using XML.
I have a program that I'm working on that utilizes a JDBC connection to a SQL 2005 server. A result set is generated from a legacy system. The data that is pulled into this result set is in the same layout as a table in SQL 2005 server.
My question is, once I have good data loaded into the ResultSet object can I pass it to the JDBC to load it into the table?
Or do I have to use the ResultSet.get(string) to pull out each value row by row, populate a string, and then use the string in an insert statement that I pass to JDBC?
Are there tricks or optimizations I can do for this type of JDBC transfer?
The package works fine in development site. It was compiled with "Enable package configurations" and sql server as configuration type. But after installed in production database using deployment manifest, the package does not load the configuration values at run time from the table, instead it uses the variables' value in design time.
If the configuration is a file in windows folder, I may be able to load it from the sql job agent's step configuration tab. When configuration values are stored in a table, how can I make it load the configuration from there at run time?
When you load the data into a new partition table, can it to done online without any downtime? because I have few tables that are around 250 gigs and more.
I have a table which is referenced in multiple stored procedures .Among them only one procedure loads data (INSERT statement) to the table. In all other procedures table is referenced in FROM clause.
My question is how do i find the stored procedure that is actually loading data into that table.
Each month we process 100+ text files into our ERP system. Occasionaly the Voucher Date in the text file does not contain a valid date. I would like to check to see if it is a valid Date, if it isn't replace it with the current date.
I thought I would use a Derived Column transformation, but I don't know how to check a field to see if it is a valid date.
can anyone help me to solve this problem i have created a ssis package to load the data from excel file to the table, but we are getting the data in different language ie in french,english and in china after loading the data when we view the data it is showing as junk characters for chinese data but we are able to see other language data ie french and english. so please tell me how to solve that reply to my mail id(sandeep_shetty@mindtree.com)