get field in a single row from union query

I have written a query that retrieve result from union. But it shows the result in two row and leave the blank column with 0. But I need the result in one row and no need the zeros. Can anyone please help me on this. Here are my query given below which I have written […]

SQL Server 2005 Getting the last record of a column

I’m new with SQL Server. I’m trying to convert my Access Database into SQL Server. Here is my problem I got a Table here. CarID CustomerName Date Replied StatusID Offer 1 Karl 05-01-2013 1 $1000 1 Karl 05-02-2013 1 $1000 1 Kathy 05-03-2013 1 $1500 1 Karl 05-04-2013 2 $1000 2 Karl 05-04-2013 1 $2000 […]

Can I join two tables from different databases?

I’ve got two different database tables which must (inner) join each other. One table comes from a MSSQL database and one is from a MySQL database. I’m almost sure it is not possible to join these tables on the database level, so I’ll have to do this in PHP (the script language I am using). […]

Catch the sp_executesql table Result

I Have Stored Procedure by using sp_executesql: USE [databasedevelopment] GO /****** Object: StoredProcedure [dbo].[SearchPaymentDev] Script Date: 06/03/2013 16:42:49 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Procedure [dbo].[SearchPaymentDev] @PayAccountin as varchar(10), @PayCustNamein as varchar(30), @PayAmountin as int, @PayAmountPaidin as int, @PayResponsein as char (2), @PayRefNoin as varchar (120), @PayScreenTextin as varchar (100), @PayReceiptTextin […]

TSQL query to merge data from multiple tables that may or may not have matching rows?

For example, suppose we’re conducting research where students can take up to 10 different tests, and each table in the database stores all the students’ responses for one test. The tables are named after each test as: T1, T2, … , T10. Suppose each table has a primary key column ‘Username’ that identifies each student. […]

Convert amount into negative depending on value in another column in SQL Server

A Table has following columns AcctNo, Dr_Cr, Amount 1111, C, 1000 1111, D, 500 The column Dr_Cr has only two values D,C Looking for a query which will output the following AcctNo, Dr_Cr, Amount, Amount1 1111, C, 1000, 1000 1111,D,500, -500 (i.e. the amount should be converted to negative when the Dr_Cr = ‘D’)

SQL Server JOIN Statements

I’m trying to pull out some information from a SQL Server database (using SQL Server Management Studio) like this: SELECT DISTINCT( t1.accountid ), t1.accountname, t1.reseller, (SELECT t1.reseller FROM dbname t1 INNER JOIN dbname t2 ON t1.reseller = t2.reseller WHERE t1.reseller IN ( 1 )) AS Reseller FROM dbname t1, dbname t2 Running this gives me […]

Can a single column of a table be grouped and concatenated into a single cell in SQL Server?

This question already has an answer here: SQL Query to get aggregated result in comma seperators along with group by column in SQL Server 2 answers

Sql Server, how can I return result where records stamped last month?

I am trying to return count of all record that where stamped as completed last month. the column name actualend his a datetime field. it is the same field where i need to make sure the record is completed in last month. This is what I have SELECT count(*) FROM PhoneCall AS p WITH (nolock) […]

How can i get all my sql server managment studio activite on my database as a executable tsql log?

We have a large Database (Many Table, SP, Function and…) and our database programers are over 10 person. All of theme can use the database on our main server computer or on his local system. Our requirements: we want each db programmer can apply his definitions (create table, triger, sp, fn &…) and modifications (on […]

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