I have a table called SrcReg which is having a column name called IsSortSeqNo smallint. I am mapping this column in SSIS and the problem comes when I try to execute against different database which has this table but the column name as ISSortSeqNo. I mean both databases having same name but one with upper case. So SSIS fails executing due to meta validation issue.Is there any way to check whether the column name is in small case or upper case through query?
Is there anyway to check if server is having disk latency or IO issues?Found below in SQL error log
Date10/1/2014 8:28:58 AM LogSQL Server (Current - 10/1/2014 12:00:00 AM)
Sourcespid10s
Message SQL Server has encountered 8500 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file [D:Fin.mdf] in database [Fin] (5). The OS file handle is 0x0000000000001368. The offset of the latest long I/O is: 0x0001104a7da000
I have a job I want to run everyday but before this job starts and I want to check and see if another job has completed before I start this job. i would like to do this in the job steps in SSMS. step 1 is job 'xxxxxxx' running if no go to step 2 if yes exit
I am looking for the best way to check to see if any columns are still NULL in a record. I have a form that gets filled out by users and the values entered into TableA. There are 6 columns in the table, 5 are responses and column6 indicates if the record is complete. So I want a way to see if all of the first 5 columns are NOT NULL and, if so, mark column6 with a 1.
I am thinking this would be a good thing for a trigger on INSERT or UPDATE to check to see if the first 5 columns are filled in and then mark the record as complete.
I have a table with a column Capacity which is char(10) and gets populated from user files. I want to check records which have negative Capacity value. So i first checked if its numeric and then for negative.
select * from table WHERE ISNUMERIC(LTRIM(RTRIM(Capacity))) = 1 AND Capacity < 0
BUT still it checks for char fields too giving errors like - Conversion failed when converting the varchar value 'asdf ' to data type int.
I have an Oracle table which contains a LONG column and I need to migrate the data from this table using SSIS to a table in SQLServer. The column in SQLServer is defined as nvarchar(MAX). This works until I changed the Oracle table to a view. The columns in the view are defined exactly the same as the source table except that it uses a database link to point to the table in a different schema. When executing the data flow task using the view, it gives me the following error message -
SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "ORA-01406: fetched column value was truncated ".
The error happens only on views with LONG column. Views with only varchar or numeric data types work fine.
Why does it work with a table but not a view which contains a LONG column?
I know how to check for a sinle vlaue but how do I chekc to see if multiple values exist. I need to check for certain email addresses from a list that I have.
Let us say I ahve 3 email addresses, I want to check for all of them in a table and for eevery email address that is present I want to print something like "You email address is XXX" and if one of those 3 is not found my results should look like
"You email address is XXX" YYYYY not found "You email address is ZZZZ"
I'm attaching some TSQL that I tried on [AdventureWorks2012].[Person].[EmailAddress]
/****** Select ALL if where an email address is present in the list ******/ SELECT EmailAddressID,EmailAddress FROM [AdventureWorks2012].[Person].[EmailAddress] WHERE EmailAddress IN ( 'ken0@adventure-works.com', --1 'terri0@adventure-works.com', --2
[Code] ....
-- Test to see if a single email address is present
IF EXISTS ( SELECT EmailAddress FROM [AdventureWorks2012].[Person].[EmailAddress] WHERE EmailAddress IN ('25rob0@adventure-works.com') ) BEGIN SELECT 'Email address is presnt'
[Code] ....
When I check multiples using EXISTS it works as per its design and says YES even if a single item is present.
I want to join 2 tables, table a and table b where b is a lookup table by left outer join. my question is how can i generate a flag that show whether match or not match the join condition ?
**The lookup table b for column id and country are always not null values, and both of them are the keys to join table a. This is because same id and country can have multiples rows in table a due to update date and posting date fields.
example table a id country area 1 China Asia 2 Thailand Asia 3 Jamaica SouthAmerica 4 Japan Asia
example table b id country area 1 China Asia 2 Thailand SouthEastAsia 3 Jamaica SouthAmerica 5 USA America
Expected output id country area Match 1 China Asia Y 2 Thailand SouthEastAsia Y 3 Jamaica SouthAmerica Y 4 Japan Asia N
I have huge export files in a DB and i need to check if there are any datasets that have the same value in the first column, but a different in another one, via a query of course.
Like this:
ID IS NULL 1 1 2 1 3 0 1 0
The expected ID i get as a result of my query should be 1 in this case.
I got a sales cost and cost amount table for my budget. the sales cost table is getting updated with FOBB items which makes the total incorrect . the FOBB values needs to be moved from the sales cost column to the cost amount column. how can i do it with an SQL script.
I wrote this query to pull some information involving 3 tables dbo.NewFamNbrs$, dbo.CGIItemMaster and dbo.CGIFamilyMaster. In addition I want to perform an update statement to update column dbo.CGIItemMaster.FamilyIDX with the information of dbo.CGIFamilyMaster.IDX. I also know that truncation is indicating that I'm trying to insert data into a field not large enough. So I performed a len() function on the both columns and order by desc and they both came up with 4 as being the max.
Query:
SELECT a.PART, a.Family, b.FamilyIDX, c.FamilyID, c.IDX FROM dbo.NewFamNbrs$ a LEFT OUTER JOIN dbo.CGIFamilyMaster c ON a.Family = c.FamilyID LEFT OUTER JOIN dbo.CGIItemMaster b ON a.PART = b.PART
Results of query:
PART Family FamilyIDX FamilyID IDX 000127233TF011468 TF01 506 000129880TF011468 TF01 506 003110 MET061468 MET06 1915
UPDATE STATEMENT:
begin tran update dbo.CGIItemMaster set FamilyIDX=c.IDX FROM dbo.NewFamNbrs$ a LEFT OUTER JOIN CGIFamilyMaster c ON a.Family = c.FamilyID LEFT OUTER JOIN dbo.CGIItemMaster b ON a.PART = b.PART
About 500 images, each about 20KB, are transferred at a time. Here is the problem - when this script is run manually, all the images are inserted completely. When the script is run as part of a job (that has several other steps), the job step completes successfully and all the images are inserted, but every single one is truncated to the first 1024 bytes of the image. What this ends up looking like on the website is a a narrow strip of image instead of a complete image. Here are some other observations:
- When I changed the "Eur_RMISWebInterface_GetProductImagesForWeb" SP to only return 1 product image instead of 500 it still failed - The owner of the job is the same Windows user as the user I have been running the script manually as - I have tried changing the datatype of image_data from image to varbinary(max) but it made no difference
When I set a column to have a default definition that uses a UDF, I am receiving the "String or binary data would be truncated" error.
The UDF:
Code BlockALTER FUNCTION GetDefaultClientTier ( @ClientAssets decimal(15,2) ) RETURNS char(1) AS BEGIN DECLARE @Result char(1) -- Get the first result in case of overlaps. SET @Result = CAST((SELECT TOP 1 ClientTier FROM ClientTiers WHERE @ClientAssets BETWEEN ClientAssetsFloor AND ClientAssetsCeiling) AS char(1)) RETURN @Result END
ClientTier is defined as char(1) in the table. I simply have (isnull([dbo].[GetDefaultClientTier]([ClientAssets])),(null))) as the definition. I can't use a computed column because I the values need to be editable. When inserting with SSIS, the insert works fine but the column has a value of null for each row.
When putting a character as the default (like 'A') the insert works fine.
The cast is there only because I have tried everything I can think of to get around this.
I have a student table like this studentid, schoolID, previousschoolid, gradelevel.
I would like to load this table every day from student system.
During the year, the student could change schoolid, whenever there is a change, I would put current records schoolid to the previous schoolid column, and set the schoolid as the newschoolid from student system.
My question in my merge statement something like below
Merge into student st using (select * from InputStudent ins) on st.id=ins.studentid
When matched then update
set st.schoolid=ins.schoolid , st.previouschoolid= case when (st.schoolid<>ins.schoolid) then st.schoolid else st.previouschoolid end , st.grade_level=ins.grade_level ;
My question is since schoolid is et at the first line of set statement, will the second line still catch what is the previous schoolid?
This should be a really simple, straight forward query, but apparently it's not. The error I get is "Invalid column name 'A'. I've put it in quotes and not in quotes and I left spaces around the equal sign and I've eliminated them. What's wrong with the SELECT statement below?
SELECT * from firms WHERE firm_id= 100002 AND active_firm = 1 AND firm_id != 100092 AND trust_id = A;
I have a database in the 3rd normalized form. There is a need to load rows into a child table. To avoid having to drop RI, an ALTER TABLE WITH NOCHECK is being used. I am looking for a way to verify the integrity after the load is complete. After the load an ALTER TABLE WITH CHECK will be executed. Can I used DBCC to verify, that no orphaned child rows were loaded? If so, which parms would I have to use with DBCC?
I have two columns. policyNumber contains a 12-13 varchar string AllPolicyNumbersIncluded contains one or more 12-13 varchar strings (policy nums) seperated by commas
I want to check if policyNumber is contained in AllPolicyNumbersIncluded?
I have policyNumber LIKE AllPolicyNumbersIncluded which works when only one policy number is in AllPolicyNumbersIncluded and incidently works switched around AllPolicyNumbersIncluded LIKE policyNumber I assume because they are equal.
Can anyone tell me how to check if one column's value is a substring of another - without going through every possible substring of the second
I have two tables namely lu_parameter and tbl_param_values. The lu_parameter table consists of param_id and parameter column containing id numbers for the parameter names.
I want to join these two tables so that in the result query instead of param_id value as column heading, I need to have the parameter value as the column heading.
We have got a query for fine tuning and it is using lot of CTE ,how can i check the execution plan of that?
CREATE VIEW Mercy AS with ADR as ( SELECT urpx.RoleID , urx.UserID FROM [DBA].dbo.URPX WITH ( NOLOCK ) INNER JOIN [DBA].dbo.URX WITH ( NOLOCK ) ON urpx.RoleID = urx.RoleID WHERE PermissionID = '1' ), SDR as (
-- Collect the roles that a configured with Sales Team Create permission
-- This will include Sales Director , Suite Admin,
SELECT urpx.RoleID FROM [DBA].dbo.URPX WITH ( NOLOCK ) INNER JOIN [DBA].dbo.URX WITH ( NOLOCK ) ON urpx.RoleID = urx.RoleID LEFT OUTER JOIN ADR ON ADR.UserID = urx.UserID WHERE ADR.RoleID IS NULL AND PermissionID='2' )
I am trying to generate a @StartDate and @EndDate. The @StartDate would be the 1st of January and the year is dependent on the @EndDate.
The @EndDate would be select max(DateValue) from dbo.testtableThe column DateValue in the testtable contains dates such as 2013-12-09, 2013-12-15.
What I am trying to accomplish is if the @EndDate is populated by select max(DateValue) from dbo.testtable returns '2013-12-15' as the max(DateValue). I want the @StartDate to '2013-01-01' because the year of the EndDate is 2013.
So something along the lines of @StartDate = DateAdd(yy,?,@EndDate)