Simple query
Hi,Input like :IDDES GoOrComePassengerAmount1Dhaka C10301Dhaka G5502Cox'sbazar C81202Cox'sbazar G785Output:IDDESCPassengerGpassengerCAmountGAmount1Dhaka10530502Cox'sbazar8712085
View ArticleTuning SQL Query
Hi All,Any suggestions/recommendations on tuning this query ? select distinct tbl1.NUMBR, tbl2.LCLTY , tbl2.NPIN, tbl2.PINN from dbo.LINE as tbl2,...
View Articlecomparing across multiple decimals
I'm trying to write a report on the versions of software we have installed and whether what's installed is up to date, ie, newer or older than our baseline.declare @var1 varchar(20) = '11.8.800.94'...
View ArticleHelp with a query using (WITH clause)
Hi there,I'm hoping someone can help me with this. Basically the query I have is working great when there is some data in the Business_Statistics table but when there are no rows I'm not getting any...
View ArticleCOALESCE Truncates Data
I am using this as my SQL Statement, the problem is that the COALESCE truncates data.Select Coalesce(Convert(Nvarchar),newspapername), Convert(nvarchar), journalname)) From CumulativeWorksCited Group...
View Articleshared lock in read committed isolation level
as per lock in sql server if a shared (S) lock has been applied to a resource, other transactions can also acquire a shared lock or an update (U) lock on that item even if the first transaction has not...
View ArticleSplit a column into multiple rows by multiple search strings
There are many posts about how to split 1 column that contains multiple items separated by a character (for example, separated by ;). My issue is a bit more complex. The string I want to search and...
View ArticleSql server regular expression- grouping of characters inside the square bracket
Hi , I am searching for a string in the table in the sql server database, for that i am creating a regular expression as I need to search with different combination. select * from table where name...
View Articlehow to update a column which has 35 millions of rows?
Hi everyoneneed helpI am updating a column which has 35 millions of records. When i start update, it is taking like > 60 mins and its not stoping (finishing).I need to null that column A, and update...
View ArticleSLA Calculation needed to exclude Holidays, Weekends and Off business hours
Hello all,I am to create a function that will calculate the minutes between two dates for company work hours, excluding the weekends. The function here from RSingh() is ideal for this purpose; however...
View ArticlePls help me to modify the query for performance improvement
Hi,I have the below initializationDECLARE @Active bit =1 ; Declare @id intSELECT @Active=CASE WHEN id=@id and [Rank] ='Good' then 0 else 1 END FROM dbo.StudentsI have to change this query in such a...
View ArticleField values from another table as column headers for query
I have the data below and would like the query results shown below also. Basically I have a generic report table where there are three potential categories and three potential aggregated values from a...
View ArticleHow to convert dateid column to getdate format
Hi All, I have a date_column which will be something like 20140202 and now i have to use this to compare to a getdate .It must be something like this where date_column = dateadd(dd, 0,datediff(dd,...
View ArticleAdd Coulumn
I have a column like Below:Code Description Season A$ B$ C$ D $10 AP FA13 3 4 5 620 BC SP15 4 5 6 710 AP...
View Articleextract data in to excel inside a stored procedure
Hi,Is there a way to extract data from a table in to excel inside a stored procedure and not using SSIS?Thanks,Preetha
View ArticleSelect query for rows where condition > 1
Say I have a table, tb1, that has the following entries:FNameLNameCode JohnDoe xxx JaneDoe xxx SteveHarper x BarrakObama x GeorgeBush xxxx BillClinton xxI'd like to write a select query that only lists...
View ArticleEliminating error during Convert from datetime to varchar
I am using SQL 2008 R2.I am using this command:select Convert(varchar(12),Cast(out_date as datetime),101) From MyTableThe output shows several rows of data and then returns an error:Conversion failed...
View ArticleNeed help with inner join and distinct rows
Hey Guys,i have 1) BaseEnv Table 2) Link Table3) BaseData TableLink table has three columns Id,BaseEnvId,BaseDataId the BaseEnvID is unique in the table where as BaseDataId can be repeated i.e multile...
View ArticleSQL Case Statement
Hi,could you please advise how to add below New case to below Main case New case:when (convert(varchar,date,101) >= '01/01/2014' OR qtr >= '14Q1') thencase when PP='ABC' and pl='EFG' then...
View Articleget value from columns using list of tables
Hi all, how do I get value from column using list of tables? For example, I have list: schema_name, table_name, column_name How do I get: schema_name, table_name, column_name, column_value?
View Article