.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

Query help required - before I pull out the rest of my hair!!

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

I have a query that I am running from a Table Function....

FROM dbo.FN(@p1, @p2)
WHERE cValue IN (1)

And I get the following error message..

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the nvarchar value '= 31' to data type int.

Yet if I run the following query with the only change being in the WHERE clause.....

FROM dbo.FN(@p1, @p2)
WHERE cValue IN (1, 9)

It runs OK. Now please can somebody explain the logic of that to me?!?! Basically if I put in a single value into the brackets it fails. it only runs when I put in more than 1 value. I will be bald before the day is over!



View Complete Post

More Related Resource Links

Use DB query result to generate Jquery required lines of code



I 'm gonna query database for photo records. each record include "photo path" where imagesURL  stored in string format

 I Choses my favorite Juqery plugin to show images. Plugin needs some lines of code like below.

How could I  generate these lines

$(function() {
sleep: 2,
fade: 1
}, [
{ src: 'picture1.jpg' },
{ src: 'picture2.jpg' },
{ src: 'picture4.jpg' }

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!

REST Query Batch Issue


Hi All,

I've got an issue when querying the listdata.svc from a Silverlight client.   

I construct the query as follows:

var parametersQuery = context.Parameters.Expand("AssociatedTask") as DataServiceQuery<ParametersItem>;

If I execute the query individually and then process the results then the AssociatedTask collection gets populated, if I include it as a batch then it does not.

I've examined the query in Fiddler and as far as I can tell the request and response are identical.

Anyone shed any light on the issue?

Sharepoint designer 2007 - Java date query - and how to disable value required for hidden fields


Hi guys,

created a list, i've managed to get field to hide and dates to populate into the applicable fields, I just have 2 queries taht I need some help with

>I need to work out how to get var tmoz to ignore saturdays and sundays - i.e. if request is raised on fri - it would default to the following mondays

>I need to work out how to mark a field as no input required if it is hidden, and input required if visible (urgent change justifacation)

 Below is the current java i'm using

<script type="text/javascript">
  function hideFieldsOnStart()
   //hide the control at start
   var control = getTagFromIdentifierAndTitle("input","TextField","Urgent Change Justifacation");
   var control2 = getTagFromIdentifierAndTitle("input","DateTimeFieldDate","Proposed Implementation Date");
   //add an onchange event to the dropdown
   getTagFromIdentifierAndTitle("select","DropDownChoice","Change Type").onchange = function() {ChangeEvent()};

SYS.ALLCOLUMNS Query required


Hi there,

I am looking for a query to check word like "COST" in all the columns, inside the table.

Any help much appreciated




List query in ASP.NET app using REST service


I cannot get this to work.  Getting an exception that provides no information.  I want to use an external ASP.NET app to query a single list in SP2010 using C# and the REST service listdata.svc, and bind the data to a gridview control.  Here's the code I have that does not work:

MySiteDataContext context = new MySiteDataContext(new Uri("http://mydevserver:1000/_vti_bin/listdata.svc"));
context.Credentials = new NetworkCredential("xxxx", "xxxx", "xxxx");

//the list name is actually Source
List<SourceItem> allSourceItems = context.Source.ToList();
var sourceItems = from c in allSourceItems
              select new {c.Id, c.Title };
GridView1.DataSource = sourceItems;

I already know the service works.  I can see the data in my browser when I go directly to the service

Ajax Query String Help Required


I developing an ASP.Net 3.5 web application. I wanted to know if there is a way to set/change the query string without complete page refresh with AJAX.. 
basically its a file manager..
It has two repeaters. One for folders and other for files in folder.
When user clicks on specific folder link button.. Files in that folder open in File Repeater.

new query - braces, case sensitivity, database names now required? TURN IT OFF PLEASE?


call me stupid or whatever, i don't care.

i have found the new query editor in 2008 have the most restrictive and pain in the a$$ feature i have ever seen.
every query now requires brackets, fully qualified dabase name + table + column for reference.

WHY am i required to type the name of the database i'm querying in a stored procedure?  COMPLETELY POINTLESS!
PLUS on top of all of that, the junk is CASE SENSITIVE.  if i wanted to waste time worrying about caps, braces and meaningless syntactical characters,  i would write code in C#.

the reason why this is SUCH AN INCONVENIENCE is that the database i am writing against has HUNDREDS of tables.
additionally, i've used 2005 for years and i really find it highly inconvenient to use the same tool as before but now i need to write queries in proper english and case.

here's a quick example: 
previously i could type 'select top 5 zipcode from shipment
NOW with the new and improved pain in the a$$ feature i have to type:
'select top 5 '[databasename].[dbo].[shipment].[zipcode] from [databasename].[dbo].[shipment]'
that might not be an exact example but you get the idea.

maybe i just don't know what the new intellisense feature is that controls this?
somebody please help me figure out how to turn off this restriction, it is

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

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

Content Query Web Part missing in SharePoint 2010

If you don't see content query web part listed in the web parts list, this is because you have not enabled "Search Server Web Parts" feature in site collection features. Enable this feature and content query web part will show in the list of web parts.

sql query that don't run



I'm going crazy... i've got a piece of code that don't update the database... Could somebody tel me why it doesn't run??

Dim conn As SqlConnection
        Dim cmd As SqlCommand
        Dim cmdstring As String = "Update Corsi Set [Contenuto]='" & TxtText.Content & "' Where [ID]='" & Request.QueryString("Id").Replace("'", "") & "'"
        conn = New SqlConnection(SqlAnni.ConnectionString)
        cmd = New SqlCommand(cmdstring, conn)

Need help with a linq to sql query


I want to display some stats in a listview contril.  The table contains a record for every impression and for every click, and every record has a datetime field for the time and date of the impression of click.  I want to be able to display how many impressions and clicks there were in a given day and hour, something like below:

Date              Time                              Impressions    Clicks
8/20/2010                                               450              14            
                     Midnight -1:00am               150               5

sql server 2005 enterprise edition is required


sql serve 2005 enterprise edition is required to work with microsoft enterprise blocks


How to send an email with information in query string


First I will say I googled (Binged to make Bill happy) for this but could not find anything, perhaps I am not stating what I need correctly;

I have a website that a customer creates orders (for a printing company) and after the order, I would like to email the customer a link to view the status of their order;

I need to send the CustomerID in the link so on the returning page if a CustomerID is detected in the querystring, I "auto login" the client and open the "Dashboard" for the order page for that customer.

Can anyone point me in the right direction as to how to send the link and how to parse the querystring to get the values from the link;

Thank you if you can point me in the right direction.

Export Dataset to excel sheet in a required format?



I know how to export a grid view to excel.

But here i have a Dataset which consists of data like below and also it need to display in a required format like below.

pno psubno pstate pdetailid pdetails

 12    1          CA         1           cbsdjcbdjc     

12     1          CA          2        cndcnjdcjcj

12     2           VA         4          xcndwkfcgygry

13     1            AL        1           ncdcnjdcndj

My excel sheet  should like this.

pid       pstate     

 12/1      CA             &nb

MDX Query parameter from SSRS


I've a MDX Query that has where clause as shown below.
I'm designing report using SSRS 2008. How can i pass date as parameter ? I tried to setup @from and @to as parameter but not working ?
any ideas....

WHERE ( {[Date Central].[Calendar Date].[2010-04-01 00:00:00]:[Date Central].[Calendar Date].[2010-08-30 00:00:00]} )

need it to work as
WHERE ( {[Date Central].[Calendar Date].[@From]:[Date Central].[Calendar Date].[@To]} )



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