When using REPLACE I'm getting an extra comma
My current SQL query using REPLACE yields the results I want but adds a "," in between spaces in the field for some reason.SELECTDISTINCT[Contract Number], REPLACE((SELECT[User Name]AS 'data()'...
View ArticleNext row
I am trying to put together a query that will find the value in the next row. Below is an example. Basically I have the start date of the term but I want the end date to be the start date of the next...
View ArticleSelect specific day for previous month
This is not really a question but more of a solution. I have been searching for a select statement for X day of previous month. There are many helpful solutions for first day and last day but I never...
View Articleoptimizing stored procedure performance using CTEs
Hi - There is a stored procedure, that has parameters, which is in need of performance improvement. I plan to rewrite it using CTEs rather than temp tables which is how it is now. From a performance...
View ArticleCorreted sub query question
SELECT a.[Property],(selecttop 1 [company_matchscore], [SAPProperty] From [ritz].[STGE_FLDACTN_SITE_MSCORE] bWhere b.[Property]= a.[Property] orderby [company_matchscore] desc)from(selectdistinct...
View ArticleProblem Solving: Create Scalar-valued Function
Environment: SQL server 2005 and Win7 Tools: MS SQL Management studio 2008 R2 Problem: How to create scalar-valued function, which generates randomly ID Numbers. Those Id number must be 9 char in...
View ArticleSql Server connectivity and script execution using Powershell
Iam designing a powershell script that can execute some sql scripts that is placed inside a folder.Actually this must be done remotely. I have an xml file having all the details needed. Powershell...
View ArticleNeed some guide line for using OUTER and CROSS APPLY in sql server
I am new familiar with OUTER and CROSS APPLY keyword and their usage. i got a article which show the little bit usage of CROSS APPLY keyword. here it is. SELECT * FROM Vehicles V INNER JOIN MileageLog...
View ArticleIndexing OTLP database for SSRS reporting system?
I have SQL Server 2008R2 and SSRS on SharePoint mode. There are no SSAS with OLAP cube.Report data are imported with SSIS during night. Service hours of Report system is 7:00-21:00 and usually there...
View ArticleQuery for Merged Data
hi, I have table called Table1 with the following structure and dataTable1------------ID Ref No Name Quantity1 0001 N1 1002...
View ArticleConsuming more time while executing Update Statement
Hi allWhen i am executing one update query it is taking much time to execute and after 40 minutes also no progress in Execution. Below is the Query: " update 'tablename' set enddate = '2014-12-31...
View ArticleHow to find similar numeric or alphanumeric in millions of record
I have a issue , i have a packet_no of 10 to 12 digits (Number may be numeric or alphanumeric ) , this packet when reaches its destination then due to bad scan one or two digits of original is...
View ArticleJunction table data insertion
CREATE DATABASE ABC_ORG USE ABC_ORG CREATE TABLE EMPLOYEE ( E_ID numeric(10) NOT NULL, E_Name varchar(20) NOT NULL, E_City varchar(10), E_Designayion varchar(20) NOT NULL CONSTRAINT PK_Emp PRIMARY...
View ArticleCreate pattern searching and expression for string datetime details available...
Hi,I have a table, where i one column whose data is date but column type is varchar(100). This date is available in all format like mm/dd/yy,mm/dd/yyyy,mm-dd-yy,mm-dd-yyyy so on.I want to create...
View ArticleJunction table select query
CREATE DATABASE ABC1_ORG USE ABC1_ORG CREATE TABLE EMPLOYEE ( E_ID numeric(10) NOT NULL, E_Name varchar(20) NOT NULL, E_City varchar(10), E_Designayion varchar(20) NOT NULL CONSTRAINT PK_Emp PRIMARY...
View ArticleModify a field & values all dtabase tables
Hello,I have problem with BIT fields & NULL values.I wish to go over all DB tables and perform the following actions:1. For every table go over its fields.2. Modify BIT field default value to 0...
View ArticleConvert string into mm/dd/yy datetime format in sql server 2008?
Hi,I have following scenario where i want to convert string date into mm/dd/yy datetime format.create table #temp1(Joining_Date varchar(100)) insert into #temp1 values ('01-Nov-2013') insert into...
View Articlesql statement
hello guys ive i have a friend uses somekind of statement in sql he says its a join statement i dont know what are the equivalent statement in modern join???here are the sample*==*(+) =thanks and god...
View ArticleHow to move the records from one table to another but number of column is...
Hi, this below query is create the table. i want move the records for this table from another table.declare @columns nvarchar(max) set @columns='['+'ID'+'] Mem_ID,'+ '['+'RefID'+'] int,' select...
View ArticleSQL 2008 R2 - how to show records based on a sub-select (2 fields)
Hi,I have one table as following:TBL_LOGS_HMAIL ############# EventType (nvarchar(5),null) EventID (int, null) TransactionID (int, null) TimeStamp (datetime, null) IPAdress (varchar(255), null) Details...
View Article