Is it possible to avoid cursor in this example?
Hello,I have a situation where the final result is being repeated because the main condition is being passed correctly. However, the primary element shouldn't be repeated.I've been playing around with...
View ArticleCan I use aggregate function within CASE?
The following query generates an error because I'm using MAX. Is there an alternative to this?I can also store it in a variable, but I prefer, if possible, that it's all in the statement.select case...
View ArticleUnique and Non Unique Records Using Row Number
Hello, I have a table which contains id, EmailAddress, Storeid,Rn . The EmailAddreses can repeat using different storeid. The table already has records with Rn ( Row Number()) applied. CREATE TABLE...
View Articlesql median in grouped query
hi, i have the sql query below for a report, i need to calculate the median Concentration for the itemtype. any body know how i can do that? the median is the middle Concentration number of the group...
View ArticleRead committed snapshot:Finding lock on table
IF update command is run on a table and commit is pending then another user cannot be able to update the table. Is there any query to get the user or PC which caused lock on the table.
View ArticleLocking in “Read Committed Snapshot”
IF update command is run on a table with "Read Committed_Snapshot" isolation level and Commit is pending eg: 1) update table1 set col1 = col1 + 1 where PKcol < 3 2) update table1 set col1 =...
View ArticleIF UPDATE (columnName) in update trigger
My understanding is that the Update trigger has a DELETED table and an INSERTED table, where the INSERTED table contains all the new data for the rows that were just modified, and the DELETED table...
View Articlenot able to view scripts in other database
I have two databases - database1, database2 userid: abcwhen I logged into database1 with userid, am not able to see database2 view scripts. Those are showing locked.My requirement - Basically, I want...
View Articleadobe pdf reader control data binding with ms sql 2012 in vb.net windows forms
I have a table in ms sql server as followingtable1 in integer pdfattachment varbinary(max)i am using vb.net windws form applicationi configure...
View ArticleHow to UPDATE STATISTICS in SQL Server 2000?
Hi All,I am trying to UPDATE STATISTICS for a table in a database and when I do so and verify the count of the table, I still get the old stats from the sysindexes table. I was wondering whenever a...
View ArticleAggregating Data and Pivot without MAX
I'd like to perform a pivot operation based upon aggregation of data - but wish to capture the the data without the MAX clause, and instead concatenate the subvalues with an asterisk between them.Here...
View ArticleBook on sql queries with multiple choice questions
Similar to book like "Test your C#.Net skills", which contains concepts and hug code snippets with multiple choice questions.Is there any book on sql server queries ?
View ArticleHow to drop several stored procedure
Hi,I got several stored procedure called PSX001.User, PSX002.Address, PSX003.ZIP and more...I want to be able to drop them all at the same time with a T-SQL command but I can't figure how to do it...
View ArticleCreate Database -> Encryption Enabled
Hi everybody.Does anyone know that, what will this option do on our database ?< "In the Create New Database" dialog , in "Option" tab, => "Encryption Enabled" >
View ArticlePivot one column
I have a query that returns data like this:VisitDt2013-01-30 10:15:00.000 2012-09-11 00:00:00.000 2012-08-17 14:00:00.000 2012-07-27 16:35:00.000 2012-06-04 14:00:00.000 2012-05-06 20:00:00.000...
View ArticleHow to get the latest row in a MS SQL server for a specific value??
Hi,This is one of the transaction tables i need for my application.DeptEmpd005b001d003b002d004b003d005b002d002b001d005b004The values in the table are inserted after enough time gap, one after the...
View ArticleHow to update the data of the table with the help of a single query.
Hello All,I have table called Useruserid gender abc M uvw F xyz M mno F pqr Mnow with in one query i need to update "M" with "F" and vice versa.How is that possible?? Please...
View ArticleVarchar Auto Number Primary Key
hi,i want a auto primary key in my table look like thisAAAAABAACAAD...AAZABA...how i do thisthanks Mohsin
View ArticleInteresting COUNT() Problem..! Help much appreciated !
I have a function which checks the database to check if the customer exists or not and if it exists in the database the query calculates how many “Ship To” address is associated with the particular...
View Article