.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

T-SQL for getting string function

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :Sql Server
Hello SQL Experts,

I have a question.... I have 3 tables (table1, table 2 and table3)

ID | meat
1 | beef pork
2 | pork chicken
3 | pork chicken beef


id type
1 beef
2 chicken
3 beef

I have table3.

I am trying to write a t-sql querythat: first it will go to table1 and check for meat column, if the column has beef then it will go to table2 and then pick the ID corrosponding to beef and then add those 2 columns (table2.ID and meat) in table3. if the column has pork, chicken and beef this process should repeate 3 times and add the 3 rows in table3.

My question is how to get the data in meat column and check if it has pork and chicken (or) chicken, pork and beef etc..... is there any string function that I can use in T-SQL. (There is a space between 2 meats types in the meat column).

Please give me some T-SQL syantx for this.

Thank you all so much
--SQL Begineer

View Complete Post

More Related Resource Links

Can't pass string to javascript function(unterminated string)

Hello,I have a problem. I can't pass string like this  ": Mar 15 2004 12:00AM  Refnr: 20040315!m>N0"to javascript function because I have symbols like these >, <, % ?tc.Situation:I have a Grid and I have column with DataItemTemplate,Within my dataitemtemplate I have <a href="javascript:void(0);"  onclick="ShowAccountStatementNote(document.getElementById('<%= lblHiddenNoteText.ClientID %>').value);" >                                                          Bekijken...                                                      </a><a href="javascript:void(0);"  onclick="ShowNote('<%# EncodeStringToHTML(Eval("Note")) %>');" > Notes </a>ShowNote function just show popup with text = NoteEncodeStringToHTML do Server.HtmlEncode(); But It doesn't help because even if we change text on server .... e.g. "dfdf%" convert to "dfdf&#37;"  anyway on client it becomes again "dfdf%" and problem still exists.On clien

Can MVC attributes with a string parameter be fed a function returning a string?


Ok so take for instance this attribute:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = "La nuova password e la password di conferma non corrispondono.")]

You can see that the third parameter is a string that I would want to localize, hence I would like to delete that message and replace it with a function call, say something along the lines of this:

[PropertiesMustMatch("NewPassword", "ConfirmPassword", ErrorMessage = GetLocalization("strErrPassMustMatch")]

Do you think it would be possible? If I got *any* chance to do it, then good, I will be setting up a system to do this :-P otherwise, I'll have to find some other way :-)

What can you tell me?

Thank you!


Pass string to Javascript function from code-behind...



I'm trying to send a error message to a javascript function from code-behind, but it's not working. When the javascript is executed the output error is: [object Object]

Here's my Javascript:

function Error(error) 
            document.getElementById("<%= errorText.ClientID %>").innerText = error;

And my C#:

        textError = "This is not working!!!";

        ScriptManager.RegisterStartupScript(Page, this.GetType(), "Error", "javascript:Error('" + textError + "');", true);                

Even if i pass the string instead of the 'textError' variable i still get the same error :(

Can anyone help me?

C# Insert string from code behind to javascript function


Hi I am using the FullCalendar plugin and I am wanting to load events from the db to the page.

In my codebehind I have a string built up of the events which need to be included.

And I need it to be inserted into the javascript function in the position shown below:

Any help???

For example:

string Calevent = "{ title: 'Click for Google', start: new Date(y, m, 28), end: new Date(y, m, 29),url: 'http://google.com/'}";

$(document).ready(function() {
        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        var calendar = $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'

How do I write a string coming from a Javascript function in my Label control?


Hi all,

This is what I tried doing in my Javascript function (partially):

catch (err) {
              document.getElementById("lblError").innerHTML = err.description;

IE output of my lblError label component is a long id name like this:

<td>Last Error: <span id="ctl00_ctl00_ContentPlaceHolder_GlobalMasterPage_ContentPlaceHolder_DashboardMasterPage_lblError">No errors at this time.</span>

how do I look up for lblLabel in this case?

Thank you

Public Function Testing (ByVal FirstString as String, ByVal FirstInteger as Integer), how to pass a


I have the following function, sometimes I want to pass a DBNULL.Value to the function so I update the database with a null value, but it won't let me as the DBNULL.Value is not a string or an integer, how can I get this to work?

Public Function Testing (ByVal FirstString as String, ByVal FirstInteger as Integer), how to pass a DBNULL.Value?

' update database

Return value

End Function

Program to find first non repetable character in a string without using any buitin function?


Program to find first non repetable character in a string without using any buitin function?

Delimited String Splitter Function with Unknown Delimiter/Rule


I am looking for the best T-SQL solution. Hints are just given for problem statement, they should not be used hard-wired in the solution algorithm. Spaces can be trimmed right & left, reduced to single space in middle. It can be assumed that the following ranges are distinquished [a-z], [A-Z], [0-9].  Lookup table support can be added as last resort.

Good luck and thanks.

DECLARE @Delimited TABLE (String nvarchar(256))

INSERT @Delimited VALUES                           

Using EXECUTE on dynamic SQL string containing scalar valued function with parameters


I would like to use EXECUTE for calling a scalar valued function as dynamic SQL and for assigning the return value to a variable. This is working fine as long as the scalar valued function does not have parameters. E.g.:



@Result bit, @Function nvarchar(MAX)

Combobox basic function. How to add a string as displayname and a string as value?


Hi, I know this is a simple question but i'm stuck...

I have a string = "my string" and I have a valuestring = "12345"

and another string = "my string2" and I have a valuestring = "67890"

and another string = "my string3" and I have a valuestring = "95123"

and so on...

I need a combobox that shows "my string's" and when that is selected a need the value "number" to be saved.


user picks "my string" and my value is "12345"


how do i do that?

Need a function to find and format initials in a string


the following rules need to be applied to initials:

- if a two letter initial is required, type them in capitals with no space or stops between them. (eg. BB Construction)

-If a name requires an initials follow it with a space with no stop (eg.  A Sander Davids)

- initials should always be in caps

I need a function that can do the above, any help will be appreciated.


SQL: Stripping HTML tags from a string by calling a function



I have a function that strips HTML from a string. But it lies in a different database to the batabase that is being queried.

My question is: How do i call that function in my query?




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

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
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