.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

String column Comparision

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :Sql Server

Hello All,

I am new to SQL. So please bare with me.

I have two tables say TABLE A( city varchar(100), clean_city varchar(100),country varchar(100))

INSERT TableA (city, country)
VALUES ('London','United Kingdom),
('Ecblondontsr','United Kingdom),
('sdclondon','United Kingdom'),
('londontres','United Kingdom'),
('thichicago','united States'),
('chicago','United States')
('3450 Mumbai','India')

Table B (Input_city varchar(100),output_country varchar(100), city_country varchar(100))

VALUES ('LONDON','London','United Kingdom'),
('CITYOFLONDON','London',United Kingdom'),
('CHICAGO','Chicago','United States'),

I want to search if city in Table A exists in input_city of tableB. If exists to set clean_city with output_city.

Is there a way I can acheive this with out using sql joins.

Any help is highly appreciated.




View Complete Post

More Related Resource Links

How to read a column of a sharepoint list to a text string field of infopath form?

My infopath form used to read these email addresses from a web service and web.config file. Now i would like to get these user email addresses from a contact list in a sharepoint server. I am trying to do this without writing any codes. Here is what i have done so far: 1. Adding a new "data connection to receive data from SharePoint library or List" where i selected Email Address column of the contact list. 2. I added a new Text Field and define a new rule with "Query using a data connection" defined above. When i try to access the newly created Text field above it always return empty as if the Query attached to it did not executed at all. What did i do wrong? Is there a better way? Thank you in advance for your help.

How to filter managed meta data column using page query string?

I have two managed term sets as follows: Articles:Downloads Projects:Downloads I am trying to use a content query web part to filter a list based on the above manged meta data column. I want to filter out only "Articles:Downloads" Scenario 1: When I edit the web part and directly set the filter option with the managed meta data column to "Articles:Downloads" it works fine. When I export the web part, in the .webpart file, the "FilterValue1" property has a value "Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910". Scenario 2: I want the web part to get the filter information from query string [PageQueryString:pageType]. So I tried using these options: a) pageType=Downloads      This works but returns downloads under 'projects' as well. (i want downloads only under 'articles')  b) pageType=Articles:Downloads     Does not work and shows no records c) pageType = Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910     Does not work. (This value is the same as one found in 'FilterValue1' of the static web part). c) pageType = Articles:Downloads|9096e43b-555d-4879-9acc-b4ada9ea9910     Does not work. d) pageType = 9096e43b-555d-4879-9acc-b4ada9ea9910     Does not work.   What am I missing here? Can some one please help?

"String Concatenation": Not appear result Or 'Null v alue' if any column contain Null null value

I write This statement to display FullName of Person SELECT CardID,( FirstName + ':' + FatherName + ':' + GrandFatherName + ':' + FamilyName) as name from PersonalData but I found he dispalay null value if any part of any columns Concatenation contain null value what the exception to make them "solution"

Caml returns table with column, whose value is empty string always, but it's not

I wrote caml query   SPSiteDataQuery query = new SPSiteDataQuery(); query.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='cmAssignedTo' Nullable='TRUE' />" + "<FieldRef Name='cmDueDate' Nullable='TRUE' /><FieldRef Name='Author' /><FieldRef Name='cmStatus' />" + "<FieldRef Name='cmControler' Nullable='TRUE' /><FieldRef Name='cmControlers' Nullable='TRUE' />" + "<FieldRef Name='FileDirRef' /><FieldRef Name='File_x0020_Type' /><FieldRef Name='cmIcon' /><FieldRef Name='cmPackageGuid' />" ; query.Webs = string .Format("<Webs Scope='{0}' />" , searchScope); query.Lists = "<Lists ServerTemplate='10553'/>" ; Fields cmAssignedTo, cmControler and cmControles return always "", but they include users! Definition of these fields is similar:   <Field xmlns="http://schemas.microsoft.com/sharepoint/" DisplayName="cmAssignedTo" StaticName="cmAssignedTo" Name="cmAssignedTo" ID="{B4B52176-1961-4b06-B7B4-C7DBB751A53F}" Type="User" List="UserInfo" ShowField="ImnName" Mult="TRUE" />   List, where i'm looking for in, includes 2 contenttypes. First one contains these

remove pattern from string as seperate column

Hey  Everyone This seems like it shouldn't be too difficult but I'm strapped for time- I have a column where the data looks like CN=kmcde,OU=People,DC=ad,DC=FLA,DC=edu I want to pull out the 'kmcde' as a new column. I'm thinking some combination of substring and perhaps patindex but can't get it to work correctly Thanks kam

SharePoint Dataview Insert New Mode - Defaulting a Required Column to a Query String Parameter Valu

I've got a SharePoint DataView with an insert button. there is a required lookup column I want to default to the value of Querystring Value during new mode.  Can I do this in the generated code below? I tried replacing @ApplicantId with @QSApplicantID.. and  tried string(@QSApplicantID) too.. no luck gave me an error: The data source control failed to execute the insert command. Could it be that QSApplicantID (which I've used in my DataView Datasource filter with no problem) is not available during the insert? I think I can do what I want in Javascript but was hoping I could instead right in the XSL markup. *my query string parameter**     ParameterBinding Name="QSApplicantID" Location="QueryString(ID)" DefaultValue="2222222"/ **the new form** SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="ApplicantId" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@ApplicantId')}" / **the link** a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}">Insert</a Thanks for any help or information!

Column Name - cannot convert between unicode & nonunicode string data types



Im using the OLEDB Source to connect the source columns. But its throwing an error msg Column Name - cannot convert between unicode & nonunicode string data types. Could you please provide me the oracle code so that I can use with the select statement. For some of the schemas I have chaged the data types using the derived column before the OLEDB destination.

Actually, one of my team member suggested me to use the Oracle char(2) in the select statement. Can any one help me with the code so that I can use it for the rest of the columns.

Eg source(External Column) - CreatedBYID - DT_wstr(18)

Source - Output cloumn - CreatedById - DTStr(18)



Importing text file datetime string into SQL datetime column



Using SSIS 2008 R2 to import text files.  Two of the fields contained are datetime values in the format "2010-09-24 18:58:29.220".  Ultimately both the date and time need to be extracted with precision to the second, at the very least.  When I import the text file, however, the time value seems to get truncated before the date value's being imported, for an imported result of "2010-09-24 00:00:00.000".

Is my problem with the Flat File Connection Manager?  Regardless of which DataType choice I use for the properties of my datetime values--I've tried every form of date datatype--the imported column values contain the correct date but the wrong time value.

Is there an easy way to import a text file datetime value straight into a datetime column?  Is it possible, or am I trying to shortcut what should be a proper process?


Importing text file datetime string into SQL datetime column



I'm importing a text file into SQL Server 2008 R2 using SSIS 2008 R2.  Included in the text file is a datetime column with values like "2010-09-24 18:58:29.220".  However, when I import the file, the stored value has the time portion replaced with what I assume is the default, such as "2010-09-24 00:00:00.000".

Is there an easy way to import a datetime value from a text file into a datetime column in my table?  I've tried every form of date datatype in the Flat File Connection Manager, but I still keep getting the correct date portion with the incorrect time portion.

Am I trying to do something that wasn't intended?  I see Todd McDermid's page (http://toddmcdermid.blogspot.com/2008/11/converting-strings-to-dates-in-derived.html) and am starting to wonder if perhaps I'm trying to shortcut something that I shouldn't.


OPENROWSET 'Provider String' Documentation? Firstrow for Text Driver, Column names in 3rd row


I'm using sql server 2008 r2 express and want to write a script to load data from some csv files.


The following gets me close:




        'Driver={Microsoft Text Driver (*.txt; *.csv)}; DEFAULTDIR=C:\Data\QOL;Extensions=CSV;',

        'SELECT * FROM RegistrationData.csv')


The problem is that the that the first two lines are not data (Report Name and time generated) and the third line is the column names. If I manually open the file and delete the first two rows everything comes out perfectly. But there are a number of these files and it has to be done regularly so I want to automate the process.  BULK options allow a FIRSTROW option but that doesn't seem to work w/o the BULK option. Is there a way to effectively skip the first 2 lines w/o the BULK option (and its requisite format file)?

DFWP query string parameter breaks column header filtering?



We have created a page (using SPD) which accepts a query string parameter to set the data filter for the DFWP. The data is displayed with a basic table layout and "sorting and filtering on column headers" is enabled. But it appears that only the sorting works. When a user clicks on the drop-down for a column header, "Ascending", "Descending", and "Loading..." is displayed. After a few seconds, "Loading..." changes to "Clear Filter" (disabled) but there is no distinct list of values to select as a filter. If we remove the query string parameter from the underlying DFWP query, it works fine. Has anyone else noticed this behavior and/or have a solution?

How can i convert Integer to String in SSIS Derived column.


i have gender column with 0,1 values

i`ve to convert it into 0=male and 1=female,i tried this


BUT it is giving error

TITLE: Microsoft Visual Studio

Error at Data Flow Task [Derived Column [46]]: The data types "DT_WSTR" and "DT_I4" are incompatible for binary operator "==". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.

Error at Data Flow Task [Derived Column [46]]: Attempt to set the result type of binary operation "Gender == 0" failed with error code 0xC0047080.

Error at Data Flow Task [Derived Column [46]]: Computing the expression "[Gender] ==0?"Male":[Gender]==1?"Female":"NA"" failed with error code 0xC0047084. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error.

Error at Data Flow Task [Derived Column [46]]: The expression "[Gender] ==0?"Male":[Gender]==1?"Female":"NA"" on "input column "Gender" (114)" is not valid.

Error at Data Flow Task [Deri

Retrieve common string in a column


Hi All,

I have a table with column Filename. it has values as below

1  SampleData1.2010_10_10
1    SampleData2.2010_10_10
 1   SampleData3.2010_10_10
 2   Yahoo1.2010_10_10
  2  Yahoo2.2010_10_10
  2  Yahoo3.2010_10_10
   3  Bing1.2010_10_10
   3  Bing2.2010_10_10
   3  Bing3.2010_10_10
i need output as

Tooltip for GridView Column Headers (ASP.Net)

I just wanted to add auto tooltips for my GridView headers. There are couple of ways but I don't want to use javascript and wanted to use simple 'title' attribute. It took couple of hours to get the working code supporting sortable columns. I thought it will be very useful for others. Here's the code and logic behind it.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.

Connestion string create any database server

This links important to how to create connection string to any data base sever.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend