sql

i want to get id through passing values in sql server 2008?

id Ptypefield Value 1 1 D 2 1 E 3 1 F 4 1 G 5 1 H 6 2 FL 7 2 IF 8 2 VVS1 9 2 VVS2 10 2 VS1 11 2 VS2 12 3 0.50 13 3 1.00 14 3 1.50 15 3 2.00 16 4 Marquise 17 4 Round 18 4 Pear 19 4 Radiant 20 4 Princess this table i want to get id no i give value like D and F this is ...

Problem with Nulls and an UPDATE statement

UPDATE TableA SET Value = a.Value * b.AnotherValue FROM TableA AS a INNER JOIN TableB AS b WHERE (Condition is true); Here is the problem. The Value field for TableA does not allow nulls. If the calculation of a.Value * b.AnotherValue yields a null, an error is thrown. Now the question. Is there any way to tell the UPDATE to ignore the...

How Do I Execute A Stored Procedure From A BizTalk SendPort?

Hello, I would like to call a stored procedure from a SendPort. I want to avoid an orchestration and instead, create a subscription to the message box based on the receive port and message type. I also need to use attributes from the received message xml as parameters for my stored procedure. My assumption is that I should use WCF-SQL ...

Is there a standard SQL Table design for overriding 'big picture' default values with lower level details?

Here's an example. Suppose we are trying to calculate a service charge. Say sales in the USA attract a 10 dollar charge, sales in the UK attract a 20 dollar charge So far it's easy - we are starting to imagine a table that lists charges by country. Now lets assume that Alaska and Hawaii are treated as special cases they are both 15 d...

Frequency Table by user in SQL

Very basic SQL question (DB is MySQL): I want a table of number of transactions by users. User ID Transaction count 1 43 2 213 3 0 4 23 5 0 In a table I have the two relevant records (user_id and buy_count). How could I get the table I want? Thanks, Roberto ...

SQL: how to get all the distinct characters in a column, across all rows

Is there an elegant way in SQL Server to find all the distinct characters in a single varchar(50) column, across all rows? Bonus points if it can be done without cursors :) For example, say my data contains 3 rows: productname ----------- product1 widget2 nicknack3 The distinct inventory of characters would be "productwigenka123" ...

Can this be done with single SQL query

I'm using MySQL. I have a table Type SubType 1 1 1 5 1 6 1 8 2 2 2 3 3 1 3 2 3 3 For each type there is some number of subtypes. For every subtype in a type there is a corresponding subtype in the next type: (1,1) => (2,2) (1,5) => (2,3) (1,6) => (2,2) (1,8) => (2,3) (2,2) => (3,1) (2,3) => (3,2) In case you haven't seen the patter...

Other solution instead of Cursoring

Hi there I have the following pivoting table that I manage to do and here's the result and I want to put a bit further. RID; NTRITCode; NTRIId; Parameter; Usage; Rate** 1; CURRENT; 4; Peak; 100; 0.1 1; CURRENT; 4; NonPeak; 200; 0.2 1; PROPOSED; 6; Peak; 100; 0.2 1; PROPOSED; 6; NonPeak; 200; 0.3 1; PROPOSED; 8; Peak; 200; 0.3 1; PRO...

C# SQL Parameter Errors in Loops

Please help me out with this. I have this small application to load txt files into a sql db and it works fine with sqlite. When I ported to SQL I started getting 'parameter already declared' errors.. If anyone can help me reorganize this code, it would be great! I need to get the parameter definitions outside of the loops or something.. ...

Deeply nested subqueries for traversing trees in MySQL

I have a table in my database where I store a tree structure using the hybrid Nested Set (MPTT) model (the one which has lft and rght values) and the Adjacency List model (storing parent_id on each node). my_table (id, parent_id, lft, rght, alias) This question doesn't relate to any of the MPTT aspects of the tree but I thought I'd le...

Seeking a GUI auto-format feature for T-SQL

Is there a freely available GUI tool that will allow interaction with Microsoft SQL Server (via T-SQL) that provides an auto-format feature? I constantly find myself writing queries in SQL Query Analyzer (Microsoft’s standard GUI tool for T-SQL) and cutting/pasting the whole thing into SQLyog (a GUI tool for MySQL), where I can press F1...

How do I create an index on a table that is non unique?

I want an index on a non-primary key column, but this column may have nulls in it. I find on a normal unique index, it (rightly so) only allows one null. Is that possible? and what is the syntax for this? ...

To share a table or not share?

Right now on my (beta) site i have a table called user data which stores name, hash(password), ipaddr, sessionkey, email and message number. Now i would like the user to have a profile description, signature, location (optional) and maybe other things. Should i have this in a separate mysql table? or should i share the table? and why? ...

Simple tool/steps for obfuscating/scrubbing production data

I am involved in a project where I need to provide subset of our production data (for a date range) to one of my co-workers for trouble shooting.I would like to insert a scrubbed subset of the production data into a new database table that my co-worker can access. Please suggest best approach to achieve this. ...

Hard code values into config.js assistance? CKEditor 3.2.1

Hello gals/guys, I am trying to hard code the bottom values into my configure.js file in ckeditor root. My goal is to hard code all submitted text as black text color and a light blue background. Values are below. How can I integrate these values into configure.js? Thanks! nano ...

LINQ Group By to project into a non-anonymous type?

Hi, I have the following LINQ example: var colorDistribution = from product in ctx.Products group product by product.Color into productColors select new { Color = productColors.Key, Count = productColors.Count() }; All this works and makes perfect sense. What I'm trying to achieve is...

Vba to Access record Insert Issue

I want to insert Values to access table by using VBA control is there is any simple way to do this. i try this code but it does not work properly if i run this code it give the error 'variable not set' can anyone help me. thanks in advance Private Sub CommandButton1_Click() Dim cn As ADODB.Connection Dim strSql As String Dim lng...

What if I don't have a column I can use as an aggregate function in my T-SQL PIVOT?

As seen here: http://www.tsqltutorials.com/pivot.php What if I don't have a column I can perform a SUM upon? How do I get a pivot'ed table result? Thanks, Matt. ...

Is this sql where statement correct?

I have 10 rows for today's date but my select statement based on date dosen't seem to work.... SELECT Id,WirelessId,RegNo,DriverName1,MobileNo1,DriverName2,MobileNo1 from DailySchedule where IsDeleted=0 and CreatedDate='2010-05-28' Any suggestion... ...

Strangest LINQ to SQL case I have ever seen

OK, so this is the strangest issue in .net programming I have ever seen. It seems that object fields are serialized in .net web services in order of field initialization. It all started with Flex not accepting SOAP response from .net web service. I have found out that it was due to the order of serialized fields was statisfying the orde...