Encoding character type in sql server column
Hello,I am having troubles during REPLACE character in sql server column due to fact that, it seems to me, SQL Server does not recognize two "the same" characters i.e., some of them it translates into...
View Articleuse waitfor dely in transaction to check locking behaviour is correct or not.
hi, I wanted know, is it good idea to test transactions using "waitfor delay",generally i put watfor delay before commit and run other queries in other query window to check locking,wether it locks...
View ArticleUpdate value in one table with value from looping through another table
I have a table(Claims) in which I would like to take all records over a certain amount(PdAmt), assign them a random number to use for sorting and then go through the records alternating assigning them...
View ArticleDisplaying selected values to be displayed in a Column
Hi Friends,I am using a table that contains TITLE,DESCRIPTION,IDFOR EXAMPLE for my title record value i have stored as,TITLE - India_35534957934Country_4356365I want to display only letters before the...
View ArticleFind matching records from two tables, useing three key fields, then replace...
I have two tables - table1 and table2 - that have the exact same schema. There are three fields that can be used to compare the data of the two tables, field1, field2, and field3. When there are...
View ArticleHow to check if value exists in sql table if not then add it from Excel file
Hi,I have one excel file having one filed called Source(Excel file has 2 fields, one of them is Source). And I have one table in SQL server name Source.So I have to check is if the Source(Field name)...
View ArticleUsing Composite Primary key of weak entity as Foreign key.
Hi,We need to use the PK USER_ID from the table USER as a composite primary key for the weak entity in REQUEST_LIST. And then, we need to use the USER_ID from the request list table inserted as mention...
View ArticleCan we know the Windows login name using T-SQL?
Hi everybody!When we start Windows 7, it asks for the User Name and password.Is it possible in T-SQL (I use SQL Server 2008) to discover this User Name?What is the SQL code that will do the...
View ArticleSelect people older than 65
Hi Guys,I'm quite new to sql. I want to make a query that retrieves al the data from people that are 65 and older. Here's what i've tried so far select...
View ArticleAudit Datetime
I have a database that is being shared in USA and Australia. Data first gets loaded in USA and full backup is sent to Australia.This database collects data from different sources. I have some Audit...
View ArticleHow to dynamically pivot on value?
Hi All,I have a table of data that looks like this:However, I needed to pivot on the Inspector Column to look like this:My problem is that these values for the Inspector field are dynamic (they can...
View ArticleSQL- Practical Exam Questions and Answer
Hi Experts ,I have been asked by my management to Prepare a T-SQL Exam paper for newly joined freshers in the company who have been given t-sql training for 2 weeks , where we could have some sample...
View ArticleQuery two table into one result
Hi Everyone,I'm trying to create a query that would query two table with some similar fields and a few unique one in one table. I was trying to create it by using "Union" but that was fruitless....
View ArticleSaving time duration in SQL Server
What's the best way to save a time duration in SQL Server 2008 R2? I have durations in a text file that are saved has Hours:Minutes:Seconds and I need to import these into a SQL Server 2008 R2 DB and...
View ArticleDATEADD and MAX() not working unless date is hardcoded
Can someone help me understand why using line 13 in the following code returns the wrong LAST_ENCOUNTER_DATE but lines 14 or 15 returns the correct date? I cannot figure out why the hardcoded date or...
View ArticleQuery help
Hi, I want a simple query to pick the MIN(Id) by doing a self join on a table.Table1ID(PK) RootId FittID Price SourceID 1 44 55 $100 3 2 45 65 $200 4 3 44 55 $300 3 4 45 65 $400 4Table2SourceID PathId...
View ArticleQuery Help.
I need to query data from "03/30/2014 2:00 A.M. through 04/01/2014 4:00 P.M.". The real sp in production is not return correct data and how can I get the result below. I have over 6 millions rows in...
View Articlehow to check for account type changes
i have a table which has data like thisCustomerID CUST_SKEY StartDate EndDate AcctType COOPCode1 123 2014-01-07 2014-01-14 OTH 20 2 147 2014-04-06 2014-04-12 TRS 12 3 789 2014-03-16 2014-03-22 XYZ 60 4...
View ArticleHow to get the weekends days for a specific date range
I want to select list of only weekend dates from a given date range. Is it possible in SQL? For example if the range is '08/01/2011' and '08/30/2011' I want a list 08/06/2011 08/07/2011 08/13/2011...
View ArticleHow to alter column to identity(1,1)
I tried Alter table table1 alter column column1 Identity(1,1);Alter table table1 ADD CONSTRAINT column1_def Identity(1,1) FOR column1 they all can not work,any idea about this? thanks
View Article