sql

Send mail in asp.net without smtp details

Hi Experts, I am using asp.net and C#. I have deployed my application on the server and now I come to know that my server would not provide me SMTP detail , is their any way I could send sms without smtp details. I can use bot asp.net3.5 with C# or SQL Server 2005 to send mail. Thanks in advance ...

Arrays in database tables and normalization

Hi! Is it smart to keep arrays in table columns? More precisely I am thinking of the following schema which to my understanding violates normalization: create table Permissions( GroupID int not null default(-1), CategoryID int not null default(-1), Permissions varchar(max) not null default(''), constraint PK_GroupCateg...

Is there any natural join replacement in SQL Server 2005?

Hi, I have two tables which I would like to join by ID field. I was trying to use for this "INNER JOIN". Everything would be good but there are two issues: As a result I receive twice column ID. I have to omit specifying columns which should be displayed under select statement. I would like to use there a *. I red that other sql-s ha...

How to handle xpath in SQL query while programming in Java

I am trying to execute the SQL statement from my java application Due website restriction on url I have replaced http=htp for this post. SELECT DISTINCT(DID) FROM (SELECT e_id DID, xml_doc xml, rownum rn from employee_master_indexes)," + " table(XMLSequence(extract(xml,'//cf:SalesReport...

Oracle - Updating one column or another based on a condition

I want to update a record in a table but based on a condition I will either update one column or another but I do not want to have 2 separate statements because the statements are very long and detailed. Here is the basic idea with over simplification to get to the point. PROCEDURE Animal_something(p_updater VARCHAR2) begin if p_...

Visual Studio error on valid SQL

I'm getting an annoying error in visual studio for SQL that executes fine. SELECT InvoiceLines.LineID, InvoiceLines.InvoiceID, InvoiceLines.Text, InvoiceLines.Rate, InvoiceLines.Count, InvoiceLines.Rate * InvoiceLines.Count AS LineTotal, ((InvoiceLines.Rate * InvoiceLines.Count) * (1 + Inv...

How not to display columns which are NULL in a view

I've set up a view which combines all the data across several tables. Is there a way to write this so that only columns which contain non-null data are displayed, and those columns which contain all NULL values are not included? ADDED: Sorry, still studying and working on my first big project so every day seems to be a new experience at...

Check services at startup of SQL Server

I am trying to check the state of services when SQL Server is started. I am using xp_cmdshell and 'sc query SQLServerAgent | FIND "STATE"' for example to load the output to a global temp table. It works when SQL Server has already started but does not work when the proc is set to autoexec, via sp_procoption. ...

How can I write this Table Valued Function as a Stored Procedure?

I have the following TVF for fulltext search: FUNCTION [dbo].[Fishes_FullTextSearch] (@searchtext nvarchar(4000), @limitcount int) RETURNS TABLE AS RETURN SELECT * FROM Fishes INNER JOIN CONTAINSTABLE(Fishes, *, @searchtext, @limitcount) AS KEY_TBL ON Fishes.Id = KEY_TBL.[KEY] When I'm using this TVF, it doesn't return a collection o...

Using SQLQuery.uniqueResult() to perform native SQL INSERTs and UPDATEs

I am using Hibernate in my project and there is a certain scenario where I want to use the uniqueResult() method on the org.hibernate.SQLQuery class to perform native SQL INSERT and UPDATE operations. I did try using the executeUpdate() method on the same class. But I get an error saying that they are used for HQL updates only. Please ...

Need to use query column value in nested subquery

EDIT Sorry for the half post :( It seems I cannot use a column from the parent query in a sub query. How can I refactor this query to get what I need? dbo.func_getRelatedAcnts returns a table of related accounts (all children from a given account). It goes up to the top level parent account of a given account and then selects all ch...

Dynamic SQL To Dynamic LINQ in VB.NET with MS SQL Server 2008

I dread asking this question, because with what I've read so far I understand im gonna have to cram a lotta new things into my head. In spite of all the similiar questions(and the wide variety of answers) I thought I'd ask as nothing I've read tailors to what I need specifically enough. I need to represent the following query using LINQ...

Query Execution Plan - When is the Where clause executed?

I have a query like this (created by LINQ): SELECT [t0].[Id], [t0].[CreationDate], [t0].[CreatorId] FROM [dbo].[DataFTS]('test', 100) AS [t0] WHERE [t0].[CreatorId] = 1 ORDER BY [t0].[RANK] DataFTS is a full-text search table valued function. The query execution plan looks like this: SELECT (0%) - Sort (23%) - Nested Loops (Inner Joi...

Finding The DSN To My Database?

I have an SQL database and want to connect to it using VBA in order to support some legacy functionality. I'm using an ADODB connection and need to know what my database DSN is. How can I find this? I'm using SQL Server 2008, thanks! :D ...

Grouping and retrieving most recent entry in a table for each group

First off, please bear with me if I don't state the SQL question correctly. I have a table that has multiple columns of data. The selection criteria for my table groups based on column 1(order #). There could be multiple items on each order, but the item #'s are not grouped together. Example: Order Customer Order Date Or...

Quickest way to fill SQL Table with Dummy Data

What is the quickest way to fill a SQL table with dummy data? I have a wide table with about 40 fields of different kinds (int, bit, varchar, etc.) and need to do some performance testing. I'm using SQL Server 2008. Thank you! ...

Using MySQL, is there any way to dump the count of records in each of all 200 tables in a database?

Say if there is a database that has 200 tables, is there a quick way to see how many records are in each table, if possible, sorted by the number of records descendingly? thanks. ...

How do I find the latest TimeStamp(DateTime) for each of my products in combination with another condition

Hi, I've two tables: Product: ProductID ProductName StateLog: StateLogID ProductID (Foreign Key) State (bit) TimeStramp (DateTime) I need to find the heighest StateLog.TimeStamp for each StateLog.ProductID there have the StateLog.State = 0 ...

Match entities fulfilling filter (strict superset of search)

I have an entity (let's say Person) with a set of arbitrary attributes with a known subset of values. I need to search for all of these entities that match all my filter conditions. That is, given a set of Attributes A, I need to find all people that have a set of Attributes that are a superset of A. For example, my table structures loo...

VBA ODBC Update

This is the code I'm using to update an SQL database: Public Sub main() Dim cnn As ADODB.Connection Dim rst As ADODB.Recordset Set cnn = New ADODB.Connection Set rst = New ADODB.Recordset cnn.Open "ConnectionName" rst.ActiveConnection = cnn rst.CursorLocation = adUseServer rst.Source = "Update Table ....