SQL Conditional Join With Same Alias

I have a join clause in a query like this. SELECT Table1.Number FROM Table1 JOIN Table2 AS Table on Table2.Table1_ID = Table1.ID JOIN Table3 AS Table on Table3.Table1_ID = Table1.ID JOIN OtherTable on Table.ID = OtherTable.Table_ID I want to conditionally join only one of the tables 2 or 3 depending on Table.Number and retain the […]

SQL server – SELECT a columns entry on a CASE WHEN query

I’d like to find out the first provider (PROVIDER_ID) to the client (CLIENT_ID) in a database table of bookings (BOOKING_ID) I currently SELECT the CLIENT_ID first, then calculate various other things. I group by (CLIENT_ID) and the count is correct. What I’m looking for is SELECT case when(min(BOOKING_ID)) then PROVIDER_ID else null end) But I […]

Putting dynamic string parameter in drop down menu server controls

I am new to .net/c# and visual studio. I have been looking all over the internet for an answer but couldn’t find it. Thanks for your help. I’m populating a drop down list from a database table, I want to pass a dynamic parameter to the asp server control (the logged in persons username). The […]

sql server query outer join where issue

I have 3 tables: Post, User and Favorites Post ———- PostId Nombre UserId Banned User ———- UserId UserName Info Favorites ———– PostId UserId I’m trying to get all posts and telling if the posts are favourites or not, so if a post isn’t among favourites, it will appear on the query but favourite flag will […]

Store XSDs in a table versus XML SCHEMA COLLECTION

I’m doing some maintenance work on an application that stores its XML data in SQL Server. Currently, the application uses another table to store associated XSDs. My question: since all XSD validation is currently being performed in ASP.NET, is there any advantage to storing the XSDs in an XML SCHEMA COLLECTION instead?

C# Connection String

I am using the following connection string within the <configuration> node. But somehow, it seems that it is not saving. Every time I use System.Configuration.ConfigurationManager.ConnectionStrings[“myDB”].ConnectionString it has a null value, and when I check the index “0” it points to .\SQLEXPRESS. <connectionStrings> <clear/> <add name=”myDB” providerName=”System.Data.SqlClient” connectionString=”Server=Server\Instance;Database=anydb;User Id=***; Password=***;” /> </connectionStrings> The projects is an […]

SQL Multipart Incorrect Syntax, Aggregate Function, Multipart Identifier can not be bound

I have been trying for several hours to teach myself and learn on how to list all customers and the orders placed by each of them with my dummy test data. I want to return the CustomerID, CustomerName, OrderTypeName, and the count “OrderCount” I have tried a few different ways and techniques found online but […]

QA SQL tables against historical data

I have two databases (MS SQL Server); one with a current set of reporting tables and another with last week’s set of reporting tables. Each week I would like to compare all the measures in each (though from week to week the row count may vary) to the previous week’s and make sure my QTD […]

Get intersecting lines in sql spatial

I’m using Entity Framework 5.0 and sql server geometry type. I’m trying to take a point and find the lines that intersect a buffer of that point and meet certain attribute requirements. Is this possible? I know of the STIntersect method but those appear to work as a comparison between two features. I have a […]

SQLSRV PRINT function issue

I have recently switch to SQLSRV from ODBC to connect MS SQL 2008 from PHP. There is a strange issue with PRINT function in stored procedure. IF PRINT function display more than approximately 700 characters, “HTTP Error 500.0 – Internal Server Error” message is return. Following are list of tools I am using: PHP 5.3.6 […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.