sql

Is it possible to update/insert data into dataset with SqlCommand?

I use this code to update data in database table. Can reuse same code to update a dataset? Thanks. using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString)) { string sql = "UPDATE tbh_Categories SET Title = @Title, Description = @D...

SQL - identifying exact matches across multiple records.

Table Parent Column1 S1 S2 S3 Table Child Column1 Column2 S1 P1 S1 P2 S2 P1 S2 P2 S3 P1 Where parent.column1 = child.column1 Given the above tables, I need to identify the parents whose children have the same records in column2 as parent S1 does. For example, S1 and S2 both have P1...

Mysql ORDER BY using date data row

I have a query something like this: SELECT title, desc, date FROM tablename ORDER BY date ASC, title ASC; Works fine when the data actually has a date. Issue is, date submission is optional, so I sometimes get 0000-00-00 as a date, which has the unfortunate effect of placing all nondated rows on top. So, I then tried this: S...

How to match two email fields where one contains friendly email address

One table has "John Doe <[email protected]>" while another has "[email protected]". Is there a UDF or alternative method that'll match the email address from the first field against the second field? This isn't going to be production code, I just need it for running an ad-hoc analysis. It's a shame the DB doesn't store both friendly and non-fri...

How to convert varchar with timezone to datetime in sql

I serialize my c# object to xml, then got varchar such as '2009-05-09T13:50:59.6361485+08:00'. But SQL Server return following messgae: 'Result: Msg 241: Conversion failed when converting date and/or time -- from character string.' after I execute following sql: declare @msg xml set @msg='<root><date>2009-05-09T13:50:59.6361485+08:00...

Create ASP.NET Syndication Feeds with SqlConnection and VB.NET

This seems to be a great article by Scott Mitchell for creating syndicated feeds in ASP.NET 3.5. The problem for me is that it uses C# and Linq, which I'm not as sharp on at the current time. http://dotnetslackers.com/articles/aspnet/How-to-create-a-syndication-feed-for-your-website.aspx Does anyone know where an example might exist f...

how to create a scheduled process in sql server

In MSSQL Server 2008, how would I go about creating a scheduled process that: Takes the sum of a float column from specific users in a user column and then comparing which is has the greatest sum and storing that number along with the user whom has that value into a separate table on a weekly basis? ...

Can't download adventure works database 2005 from codeplex

Can't download adventure works database 2005 from codeplex. Where else can I find and download it??? I've been searching it online, I found some results but i can't download any of them. Any help is appreciated ...

operating system information from a microsoft sql server instance

Does anyone know how to get the operating system information from a microsoft sql server instance via sql? Using SERVERPROPERTY can get some information but I need to get the operating system e.g. 'Microsoft Windows NT 5.2 (3790)' Thanks ...

How do I mark duplicates in a given group in MySQL?

I have the following table structure (in MySQL): DocID, Code, IsDup, DopOf , where DocID is Unique. Values are like : 1,AAAA,nul,nul 2,AAAA,nul,nul 3,AAAA,nul,nul 4,BBBB,nul,nul 5,CCCC,nul,nul 6,CCCC,nul,nul What I want is to write a procedure which can update the table and give the desired result as: 1,AAAA,0,0 2,AAAA,1,1 3,AA...

Deleting hierarchical data in SQL table.

I have a table with hierarchical data. A column "ParentId" that holds the Id ("ID" - key column) of it's parent. When deleting a row, I want to delete all children (all levels of nesting). How to do it? Thanks ...

SQL -- Selecting Top 1 with Order by?

This was resolved. The statement was in another part of the stored procedure. The stored procedure I'm writing won't allow me to do this: declare @dtTopDate datetime select top 1 @dtTopDate = date_build from database..table where database..table.parent = @Parent and database..table.child = @Child order by date_build ...

How can I call a stored procedure from Crystal Reports?

I have a stored procedure that takes a user ID and calculates their balance with a really simple query and returns it. I want to add this to a crystal report in my application. The only problem is, Crystal Reports wants me to set a value for the procedure, and setting a single value for it would be useless to me. I have everything group...

SQL Server SET DATEFIRST scope

I'm using SS 2005 if that I've seen sample code like DECLARE @restore = SELECT @@DATEFIRST SET DATEFIRST 1 SELECT datepart(dw,ADateTimeColumn) as MondayBasedDate,.... FROM famousShipwrecks -- SET DATEFIRST @restore Suppose while the query is running another query sets DATEFIRST? If another query relies on datefirst being 7 (for exam...

SubQueries in MS ACCESS: selecting only one record per "person" per date.

I am using a table called analyzed in Microsoft Access. It has many fields but the three ones being used for filtering in this case are analyzed.readings_miu_id, analyzed.ReadDate, analyzed.ReadTime. I need to pull the records from the "analyzed" table where readings_miu_id are grouped together then sorted by ReadDate but showing only th...

How to make Linq to SQL translate to a derived column?

I have a table with a 'Wav' column that is of type 'VARBINARY(max)' (storing a wav file) and would like to be able to check if there is a wav from Linq to SQL. My first approach was to do the following in Linq: var result = from row in dc.Table select new { NoWav = row.Wav != null }; The problem with the code above is it...

Deciding on a database structure for pricing wizard

Option A We are working on a small project that requires a pricing wizard for custom tables. (yes, actual custom tables- the kind you eat at. From here out I'll call them kitchen tables so we don't get confused) I came up with a model where each kitchen table part was a database table. So the database looked like this: TableLineItem --...

How do I back up a database to a .bak file?

Hi, I have a website I've created in Visual Studio 2008 and I need to take it live. How can I backup the database file to a .bak so I can hand it over to the hosting company to place on the server? ...

Recovering types through an Isa relationship

Hi! My database has 7 tables: one is the parent (feeds) and the other 3 are the children (public feeds, private feeds, generated feeds) of an isA relationship. There is a table "subscriptions" with a foreign key on the feeds table. Each user can subscribe a feed of any type. The problem is that the view for each type of feed is different...

How can I use more than one Stored Procedure in a crystal report?

I have two stored procedures I wish to use in my stored procedure, but once I do that it fails to load with the error: "Invalid Argument provided, no rowset retrieved." If I remove either one of them it starts working again. I have the crystal report set up something like this: Report: Group By Tenant.ReferedBy stored proc here t...