sql-server

How can data vary pending how I view them

I have an odd case where when I look at the data through my SQL scripts I have one value, but if I look at the data directly SELECT * FROM table I get another value. My first thought was parameter sniffing, but that didn't fix the issue. I'm not doing anything with the value at hand, except getting it with a stored procedure. Example o...

Full Text Search Help

In a SQL Server database I've two tables: Job and JobKeyword. Each Job has JobKeywords. I'm trying to learn how to use Full Text Search. How can I get a list of all jobs in the databases, ordered by shared keywords between the search query and the jobs? ...

transport-level error when specifying SELECT *

The following query does not work, and produces an error: A transport-level error has occurred when receiving results from the server SELECT * FROM table1 a, table2 b, table3 c WHERE a.location = b.location AND b.location = c.location AND a.id = c.id AND a.entry = ''34690'' Although this ...

Query (SQL Server 2008 Express) works in SQL Server Management Studio but not in Delphi using ADODB

Hi, I have the following query: WITH cte AS ( SELECT windowId, frameIndx, elemIndx, comment, ROW_NUMBER() OVER (PARTITION BY frameIndx ORDER BY elemIndx DESC) AS rn FROM dbo.translations WHERE windowId = 1 AND frameIndx IN ( SELECT indx FROM...

staircase behavior with pivoted data

Hail to the fellow programmers and query writers, I have this beautiful query SELECT ID, [1] AS coL1, [15] AS coL2, [2] AS coL3, [16] AS coL4, [12] AS coL5 FROM MY_TABLE PIVOT (sum(INT_VALUE) FOR FUND_CODE IN ([1],[2],[15],[16],[12])) AS p --GROUP BY ID, [1] , [15] , [2] , [16] , [12] ORDER BY ID ASC That returns me data like this:...

Problems with sending notification emails from SQL Server 2008

Hi, I have a problem setting up email notifications in SQL Server 2008. I am using SQL Server 2008 to build a data cube. This process consists of several jobs, that are all scheduled to run each night at a specific time. To see whether a job was running without any failure, it is possible to set up email notification. Unfortunately,...

Can you explain the use of sys.sp_addextendedproperty in the following code?

What's going on in the following code after the View is created? Can you give me any thoughts or path to follow? This code is taken from here. /****** Object: View [dbo].[vProductImages] Script Date: 04/28/2008 16:59:05 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE VIEW [dbo].[vProductImages] AS SELECT dbo....

Group and concatenate many rows to one

I want to "concatenate" all the "Text"-rows into one single row and get one row as a result. Is this even possible? I use MSSQL Server 2005. ...

How large to make name fields in database?

There's an old question that asks this very thing, but a lot has changed in databases and unspoken standards. I generally live by the rule as to never make a field size text or memo, even if it speeds up the database. Primarily because someone could flood and possibly hack the db if there are no restrictions in the input interface. ...

advice on best practice when connecting ASP.NET application to SQL Server

I have an ASP.NET application that uses the membership functionality. I connect to a SQL Server database that contains the aspnet_membership schema. I currently am using "sa" and the sa password in my application's connection string which, I know, is a horrible thing to do. My question is, what is the best alternative for the connection ...

Grant access to INFORMATION_SCHEMA

We have a utility that does some SQL magic by reflecting the definition for some views and stored procs. For this to work, the code needs access to various fields in the tables INFORMATION_SCHEMA.ROUTINES, INFORMATION_SCHEMA.VIEWS, etc. So we wrote a cursor that applies GRANT VIEW DEFINITION on ' + @Name + ' TO tenant' where tenant i...

Script to find and replace function

Hi All, We have changed some base functions we use in an application and I am trying to figure out what the best way would be for me to find and replace the existing function with the new one? The input / outputs don't change, just the schema and some of the internal logic. Is there a good approach to finding the objects (views, proc...

How can I use aggregate function SUM on an alias column?

Invoice ID, PO Number and dueDate are shown in duplicates. TotalPrice is an alias (It should be Unit Price, total price is a mistake, so assume it Unit Price not total price) TotalShippingPrice shows the shipping price that was associated with the InvoiceID/PONumber, for every invoiceID/PONumber there will be single shipping price. Sa...

Varbinary always is null at WCF service

my DAL is something like this: Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>(); mylist = db.ExecuteSprocAccessor<EMyClass>("spMySP", param1, param2).ToList(); my SP in SQL-SEVER returns 4 normal fields plus a varbinary field that is an image my EMyClass is: public class EMyClass { public int aaa { get; ...

SELECT Statement - NOLOCK with SET TRANSACTION ISOLATION LEVEL READ COMMITTED

My understanding is that when NOLOCK is used in SELECT statement, it could read uncommitted / dirty rows as well. But I wanted to take advantage of NOLOCK hint on table so that my SELECT query will run fast. Now, does NOLOCK on table but along with "SET TRANSACTION ISOLATION LEVEL READ COMMITTED" give me NOLOCK advantage and faster SE...

is it possible to mimic the functionality of ms-access with c#?

i have a split front-end and back-end access database. i am planning to move it into sql server. the front end will be c# linq to sql. question: is it going to be possible to have multiple users use this c# front end and for example be able to edit a table at the same time? you know that ms-access you can design a form with a table on i...

Need Help in Calculating Working Hours

The way i designed my working sheet doesn't help me to calculate working hours easily. The output in snapshot has been gathered from multiple tables. Don't worry regarding setDate and timeEntered formatting. SetDate represents working day. tsTypeTitle represents type of shift, is it lunch time, etc. timeEntered represents the actual...

Table with Select Statements, Executing Dynamic SQL and Returning Values

I have a select statement that returns a table full of SELECT statements (It goes through every column in every table and creates a select to find if that column contains any bad data). I need to take this table full of SELECT statements, execute them, and see if any of them return rows. If the count(*) > 0, then I want to print out ...

how to determine size of row in the database

Possible Duplicate: Size of varbinary field in SQL server 2005 In my SQL2005 database, I have a table that has a column varbinary(MAX). How do I tell the size of the rows? Or as an alternative, tell the size of the varbinary field in each row? ...

How to create a result set from a select query using multiple joins AND pull values from unlinked table where certain values exist

I have a table which contains values for a collection of data. The value field thus contains multiple types of data - dates, numbers, text. One of the fields in the collection is a lookup to another unlinked table. I can figure out the select for the collection but not how to also pull in the value from the unlinked table. SELECT DIST...