sql

WCF Impersonation and SQL trusted connections?

We have a service that is hosted under IIS7. The connection string for the SQL server is set to Trusted. In order for the authentication to happen I need to setup impersonation on the service and have the client initiate an impersonated connection. Is there a way to not have impersonation set and still allow the service to log into the...

Getting image height and width when image is saved in database

Hi I save my images into my SQL Server Database with ASP.NET(2.0). (imageData -> image) (imageType -> varchar) (imageLength -> bigint) Thus the imageData will be "Binary data" and the imageType will be like "image/gif" and the imageLength will be like "6458"....... Is it possible to get the image HEIGHT and WIDTH from my VB.NET code ...

Query several EAV attributes in separate columns

I am facing issues trying to write a query. (this is slightly modified from my previous question) My tables are laid out as follows: tblTicketIssues.TicketID tblTicketIssues.RequesterID tblPersonnelProfile.PersonnelID tblPersonnelProfile.FirstName tblPersonnelProfile.LastName tblTicketAttribute.TicketID tblTicketAttribute.Attr...

How to embed image in html and send html as email by msdb.dbo.sp_send_dbmail?

I can use msdb.dbo.sp_send_dbmail to send out email in html format. It is very nice for text only in terms of format. For example: EXEC msdb.dbo.sp_send_dbmail @recipients = @p_recipients, @subject = @v_subject, @body=@emailHTML, @body_format = 'HTML'; However, if I want to include images such as trend generated from data on ...

Copy data from one existing row to another existing row in SQL?

OK so I suck at SQL and I always have to ask for help, not sure what my disconnect is because I don't have any problem with programming C like languages, here is my challenge: I have a table full of tracking data for as specific course, course number 6. Now I have added new tracking data for course number 11. Each row of data is for o...

SQL: Delete rows from two tables

I have two tables. Those tables have two relation between them. Table 1 * ID_XPTO (PK) * Detail Table 2 * ID_XPTO (FK) (PK) * ID_XPTO2 (FK) (PK) Those two relations exists. Table 1 -< Table2 Table 1 -< Table2 My question is that I need to delete some row in table 1. I'm doing on that way declare @table Table (xptoTabl...

Why would "Where 1 <> 1" in a query return all rows?

I've come across a query in an application that I've inherited that looks like this: Select * From foo where 1 <> 1 As I parse that, it should return nothing (1 <> 1 should evaluate to false, right). However (at least on my Oracle box) it comes back with a full listing of everything in foo. When I try the same thing in MSAccess/Je...

oracle 10g - Monitor large row deletions

how can i monitor rows being deleted(say 20 rows)? consider, i am a dba and monitoring an oracle database.. i have to get an alert if someone deletes more than 20 rows.. i should avoid a trigger since it is costly.. is there any other way around? how can i parse the redo log and trap the sql that might have caused a bulk row delete? m...

SQL to replace smart quotes

Does anyone know a SQL command to replace MS Office smart quotes with their ASCII cousins? I'm using an oracle database and the fields are of type varchar2 ...

Using SqlCommand to execute a non-query, can you get to text normally posted to "Messages"?

When using SqlCommand to execute a non-query (such as a database restore), is it possible to programatically get the text that would normally be posted to the "Messages" tab if using the Management Studio? And if so how? ...

Best practices for column naming in Sql

Say I have a table called Student. Which of the following naming conventions do you prefer for the columns? You can also suggest your own. Student ------- StudentID StudentName MentorID Student ------- StudentID Name MentorID Student ------- ID Name MentorID ...

Scalable Database Tagging Schema

EDIT: To people building tagging systems. Don't read this. It is not what you are looking for. I asked this when I wasn't aware that RDBMS all have their own optimization methods, just use a simple many to many scheme. I have a posting system that has millions of posts. Each post can have an infinite number of tags associated with it. ...

C# constructing paramater query SQL - LIKE %

I am trying to build SQL for a parameter query in C# for a query which will contain the LIKE %% command. Here is what I am trying to acheive (please note that the database is Firebird) var SQL = string.format("SELECT * FROM {0} WHERE {1} LIKE '%?%'", TABLE, NAME); Cmd.Parameters.AddWithValue(NAME, "JOHN"); Now I have tried every sing...

SQL IN clause slower than individual queries

I'm using Hibernate's JPA implementation with MySQL 5.0.67. MySQL is configured to use InnoDB. In performing a JPA query (which is translated to SQL), I've discovered that using the IN clause is slower than performing individual queries. Example: SELECT p FROM Person p WHERE p.name IN ('Joe', 'Jane', 'Bob', 'Alice') is slower than fo...

Right way to use MySQL to assign tasks to worker processes

I have a huge list of URLs in a MySQL InnoDB table, and worker processes that query MySQL for a set of URLs to process. The URLs should immediately be marked as being processed, so that other worker processes do not waste resources by starting to process the same ones. Currently I first do this to get some URLs: SELECT DISTINCT url FRO...

Is there an equivalent to MS SQL 'FOR XML PATH' in other database products?

I am currently using Microsoft's FOR XML PATH feature to pull data back from MS SQL Server in an XML format. I really like the feature but am always uncomfortable about using vendor specific functions. Do any of the other major database vendors have something similar? Edit Let me be more specific with type of features I'm looking for...

backup MSSQL via C#

How easy is it to backup a Database via C# code? I see lots of related questions, but no real answers. ...

How can I write my SQL query in LINQ?

I have a table that looks like this. The query needs to return the last date entry for each location. How would I write this in SQL and LINQ? Id Location Salary Date 1 Los Angeles $1500 Jan-05-1999 2 San Diego $250 Jan-07-1999 3 Los Angeles $300 Jan-08-1999 4 Boston $700 Jan-08-1999 ...

SQL update Query

We have combined primary key with fields no, id and groupno From Access, a WHERE condition such as WHERE no = '' & groupno = '' executes faster while the same thing slows down updates in SQL. Once we have provided individual index of no & groupno, will it be faster? Does it consider it as a combined key if we provide primary key with ...

data access in silverlight 2.0

i'm new to silverlight and i'm porting from asp.net 2.0. I have done many data binding applications in asp.net where i use sql server 2005 and use it's tables and access them via sqlconnection object and perform all kind of database related functions. Can any one tell does silverlight 2.0 supports such kind of facility. If so can i use a...