Querying previous months data
I have been tasked with pulling the previous two months of data from a table. The view looks like this.SELECT TOP (100) PERCENT ItemNumber, SUM(ABS(CAST(ROUND(TransactionQty, 2, 1) AS DECIMAL(9,...
View ArticleHow to extract 250,000 Records into excel
Hi Friends In sql server My table has 250,000 records . How can I import these records into excel?If not which file type I can use for it. Thanks for advance friends
View ArticlePerformance updating a extra huge table
Hi guys, just an advice. I'm handling table with more than 300 millions rows, sometimes even 800 millions and so far I came up with some good solution but now I really need to be concerned about the...
View ArticleConvert Access SQL to SQL Server SQL
Below are my two query's top is from Access bottom is from SQL Server. I know the access query is correct, but for some reason they are both returning different values. What did I type incorrectly in...
View ArticleLooking to improve slow running query
Hi,Is there any way of rewriting this query to make it more efficient? It's running pretty slow for me and If there are any glaring problems with the way its been written I'd like to fix them.SELECT...
View ArticleHow to send one single mail each time a table is updated with a batch of rows
Hi!I would like to send one mail each time an integrations services inserts a batch of rows. I,ve tested with this code but it sends one mail for each row that is inserted to the table. How to adjust...
View ArticleRe-Arrange Columns?
I have a query that gives me the data that I want. I am being asked to present it is a certain format and I just can't find how to do it. I hope I am in the correct forum to start. I will post my sql...
View Articlehow to search all Last name of Like use SqlServer ?
example : result After search for all last name of like in column [Full name]: Full name jon adil sara adil almn adil bork adil...
View Articleconvert datetime to date/very urgent
Hello expertsi am new to sql server and wants to change a column data type datetime to date in a view and i need to document that also, thank you.
View Articledaterange
I'm executing the below code i'm getting output as below. DateFromDateTo 2014-01-01 00:00:00.0002014-01-20 23:59:59.000 But why i'm missing2014-01-21 00:00:00.000','2014-12-31 23:59:59.000'DECLARE...
View ArticleDateRange
hi Experts, Could you Please help me on this query..I have @startdate ='2012-01-01 00:00:00.000', @Enddate = '2014-01-31 00:00:00.000'in the table i have dateranges define if the...
View ArticleFiltered index
I would like to create filtered index:WHERE col1<col2but it is not allowed. If I create computed column(col3=col2-col1) and use filter col3>0 it works, but as I remember there are some problems...
View ArticleSelect Statement with an "In-Line" Condition
I will try and keep this as simple and straight forward as possible. I want to generate a Select statement that will get me all my Products and their weight from my SQL database. I would like to...
View ArticleGROUP BY to combine/concat a column
Hi,SELECT tblFuelCostDetails.TripId, tblFuelCostDetails.PurchaseDate, tblPetrolPumps.PumpName+CONVERT(nvarchar(50), tblFuelCostDetails.Quantity) as Pump FROM...
View Articlequery help
helle Experts..I have below table.My requirement is to get Number of Saturdays and Sundays which have values '0' within a given date range.Ex: Startdate= '2014-01-01 00:00:00:000',enddate = '2014-01-20...
View ArticleHow to get tab delimited text file when Stored Procedure executes ?
Hello Everyone,I have a stored procedure which returns 1 result set as an output.I want the output as a Tab Delimited Text file.I know that I can use SSIS and get the same output but I am not allowed...
View ArticleHow to retrieve data based on month end dates
Hi guysI need to get last 6 months of data grouped by month end dates....I need to automate this query so that it always looks for date for last 6 monthsHow do I achieve this?For ex my database has a...
View ArticleUsing CASE WHEN to check multiple rows of a table
So I have a table called MATERIAL with a field named MATERIAL_SHIPPED. It will either have a 1 or 0 value making it as shipped or not.There may be multiple materials for each PROJECT record. I want to...
View ArticleMerge statement syntax for not matched not working
I'm receiving an syntax error on the statement below. None of my corrections seem to be working. Have something similar working on another server with 2008 r2. MERGE INTO...
View ArticleCertificated stored procedure going squiffy
I have a certificated SP on DB1 using a linked server to DB2. Inside the SP is "Execute as login='LinkUser'" where LinkUser is allowed to be impersonated by the login attached to the certificate...
View Article