sql-server

SQL use nested select in middle of inner join

Is it possible to use a select in the middle of joining... I am trying to do the following: FROM tblorders o INNER JOIN tblunits u on o.id = u.orderid INNER JOIN ((SELECT ,Min(n.date) as [MinDate] from tblNotes n Where n.test = 'test') te INNER JOIN tblnotes n on te.id = n.id ...

AppFabric monitoring issue, events won't travel from ASStagingTable to ASWcfEventsTable

I'm trying to get AppFabric monitoring to work but I'm stuck here. Events are being inserted into the ASStagingTable but they don't propagate to the ASWcfEventsTable. They do if I manually run the ASImportEvents sp. I use SQL server 2008 worksation edition on Windows Server 2008R2. I've verified that the AppFabric Event Collection Servi...

Select Distinct for 2 columns in SQL query

If I have a table such as 1 bob 1 ray 1 bob 1 ray 2 joe 2 joe And I want to select distinct based on the two columns so that I would get 1 bob 1 ray 2 joe How can I word my query? Is the only way to concatenate the columns and wrap them around a distinct function operator? ...

T-SQL: Selecting Column Based on MAX(Other Column)

I'm hoping there's a simple way to do this without using a sub-query: Scenario: You have "TableA" with columns "Key", "SubKey", and "Value". I need to get the "Value" of the MAX("SubKey") for a given "Key". So if the Table contained the rows: KEY SUBKEY VALUE 1 1 100 1 2 200 1 3 300 For Key = 1, I need the val...

SQL Server 2005 FTS unexpected results

I have an Indexed View with two columns, a primary key char and a field for full-text indexing varchar(300). I need to search from a MS Great Plains database, so I created the view to populate a field with concatenated values from my primary table IV00101. CREATE VIEW SearchablePartContent WITH SCHEMABINDING AS SELECT ITEMNMBR, rtrim(I...

Hot to auto-generate TWO unique identifiers for an association table in SQL 2008's Design view.

I'm using the shortcut, via properties. When i only need to generate one identifier, i set "(Is) identity" to "Yes", but i can't seem to do it for two rows. Please Help. ...

In generating a Linq to SQL class, how can I define a complex relationship?

I have two views: one is a normal view built from one table with an integer ID and other columns for the record (let's call it View1). I have another View (View2), which has an integer ID column and a second column named "table" (type: varchar). That second column contains the name of the table to which the ID column is related: So, i...

SQL Server Drop Table

If you drop a table in SQL Server that has Keys, Indexes, Contraints, etc on it will it drop those as well? I was just wondering when I am building my scripts if I need to create drop scripts for all of those as well or if I can simply drop the tables? Thanks, S ...

Find all references to an object in an SQL Server database

I'm trying to find all references to an object in an SQL Server database. How can I quickly search? SQL Server Management Studio does not seem to do it. I use http://www.red-gate.com/products/SQL_Search/ but I'd like to find the "official" Microsoft solution to this. Is it in another product? For example, when I do a mass search in vis...

Having problem generating a certificate request from a sql 2005 server

Hi all, I'm trying to generate a certificate request from a sql 2005 / windows 2008 server, so that i can get a certificate made and thus enable encryption on my sql connections from clients. On the server, i do: start -> run -> mmc add 'certificates' snapin choose 'computer account' choose 'local computer' Right click the Certificat...

executing SELECT statement with date in WHERE clause fails

I'm building a dynamic query in my ASP.NET MVC project by the following: Dim queryString As String = "SELECT VALUE userInfos FROM MyDBEntities.UserInformations AS userInfos" If strWhere <> "" Then queryString = queryString & " WHERE " & strWhere End If ' Call the constructor with the specified query and the ObjectContext. Dim Sear...

How to Show Eastern Letter(Chinese Character) on SQL Server/SQL Reporting Services?

I need to insert chinese characters in my database but it always show ???? .. Example: Insert this record. 微波室外单元-Apple Then it became ??? Result: ??????-Apple I really Need Help...thanks in regard. I am using MSSQL Server 2008 ...

microsoft reportviewer

anyone has a code sample to connect the Microsoft Report Viewer Control using Microsoft SQL Server stored procedure? ...

How to save the last serial value in Postgres?

This is how I do in SQL Server: insert into users(name, password) values('admin', '1'); declare @id int; set @id = @@identity; insert into usersroles values(@id, 1); insert into usersroles values(@id, 2); @@identity is in sql server the last inserted identity (serial) How to do the same in Postgres? ...

group by clause in sql server 2005

i have table called table1 and it looks like the below record type tran_ref_number amount customer_name TRN 123 15000 sara TRN 234 25000 inba TRN 345 20000 rajiv TRN 45...

Need help with Asp.net beginner login app

created this simple login page..it's supposed to display in the label text like "Wrong user " when user doesn't exist.."Wrong password" when password entered is incorrect etc but whenever i try and login it ALWAYS displays "Wrong user" when the user does exist in the table..have entered usernames and passwords manually..not using any st...

How to Nested Case in Select SQL?

I have this select Case SQL statement which compute the totalvolume of a given quantity. SELECT DropshipPackinglist.CaseNumber as 'CASE NO.', DropshipPackinglist.ItemNumber as 'BOM NO.', DropshipPackinglist.Quantity as 'QTY', CASE WHEN DropshipPackinglist.Quantity >=31 and DropshipPackin...

How long should the connectionString timeout be in ASP.NET applications? (sqlclient)

In my ASP.NET application, I have a sqlclient connectionstring in my web.config file, What is the recommended timeout setting for production environment? Default is 15 seconds. My web farm and database cluster are on the same switch, so there should not be much latency. ...

difference between varchar(500) vs varchar(max) in sql server

I want to know what are pros and cons while using varchar(500) vs varchar(max) in terms of performance, memory and anything else to consider? Will both use same amount of storage space? Is the answer differ in case of sql server 2000/2005/2008? ...

Sql Server - connect with windows authentication

Hello, i must connect to a sql server with windows authentication sql server is on machine 192.168.3.6 web server (client) is on my machine 192.168.3.10 I'm using JTDS driver dbUrl=jdbc:jtds:sqlserver://192.168.3.6:1099/db_test;instance=test Connection con = DriverManager.getConnection( dbUrl, "", "" ); I have username and password ...