round up or down to nearest dollar
I would like to be able to round a money field to the nearest dollar based on the following rule:50 cents or less rounds down to zero. 51 cents or more rounds up the the next dollar.for example, $4.50...
View ArticleExtract min timestamp from string
Hello all,I am trying to query the minimum datetime from a column that is stored as nvarchar(max). There a a few tricky things with this query (at least for me)- There is more than just the date being...
View ArticleFinding the time spent between two consecutive actions
Hi All,I have a table with the following columns:Date datetimeQueue varchar(50)Agent varchar(50)Action varchar(10)Records are inserted into this table in sequential order (based on Date), and the data...
View Articleerror in pivot statement in sqlserver
Hi All,following is my working code.i have created temporary tables anybody can run this code declare @dte as datetime ='2013-10-01' declare @StDt as Datetime = DATEADD(dd,-(DAY(GETDATE())-1),@dte)...
View ArticleCompare columns and INDEXES Between SQL Tables
I have a process where I have several tables such as 200 tables eg TABLE1_Current, TABLE2_CURRENT and so on.. Each table also has a backup table called TABLE1_Backup, TABLE2_Backup and so on. Like...
View ArticleBest options to use in Temp Table
Hello,I was just trying to figure out the best options we can choose with when we come across a scenario where we need to use a Temp Table/Table Variable/Create a Temp Table on the fly.However, I...
View ArticleCan we rollback the update query using Transaction?
Can we rollback the Update query by writing the update query with in the transaction, as i am implementing different update queries, sometimes I am mistakenly updating the table without where criteria,...
View ArticleOpenquery SQL 2014
Is openquery still the way to query an Oracle linked server in SQL 2014? When researching how to setup an Oracle linked server I could have sworn I found an article saying openquery was deprecated, and...
View ArticleRank - no null
Declare @test table ( calldate date, calllogid int, id int ) Insert into @test select '2013-12-02', 52713, 48287 Insert into @test select '2013-12-02', 52713, 271 Insert into @test select '2014-05-01',...
View ArticleIdentifying the column match from an in clause
Greetings all,I have a dynamic query which populates a pseudo lookup table. It can (currently) populated anywhere from 1 to 8 columns, with an associated description.Joining to the results of this...
View ArticleSelect unique records
I have a query that returns the results I want, but I need to get just unique records, but still return 25 records after dedupe.SELECT TOP 25 [StartTime], [EndTime], [CallerURI], [CallerIPAddr],...
View ArticleHow to tell what rows each developer has changes in a database ?
Hi All,In my previous job we used to have an open source tool in SQL server I think it was called (tortiseCVS) this tool will allow me to see what SQL server databases has been changed and who did...
View ArticleHow do I locate variable length data types with lengths of 2 or less???
How do I locate VARCHAR datatype where the lengths are 2 or less? I want to search the table list on a particular instance.
View Articledatatype conversion error.
hi Friends,i have create one function and its function having parameter number which is in decimal.but my datatype of this column in table is NVARCHAR.now m execute this function like.. RETURN...
View ArticleStored procedure inserting in multiple tables orphans records. How to handle
I have stored procedure that inserts information into a login table and a announcer table. I have realized that when insertion into the announcer fails, a record was inserted into the login table,...
View Articlelocating stored procedures that start with ‘sp_’
How do I query and find stored procedure that start with 'sp_'?
View Articlehow to apply business rules with out breaking to patch missing data
Hello Experts, I am very new to SQL And i have no idea how to apply below rules Data is polling for every 5 minutes so 12 time intervals per hour 6:00 -->1...
View ArticleHelp in query please
Hi, How I can get the exptected output. I wan to join both table.I want to get correct the actualtravaldate. I have dates in #travalplan. These dates should match with the dates of actualtravaldate, if...
View Articlemultiple aggregation using pivot in sqlserver
I have a table Events Events containing cardno,time,id,name--each id has a cardno my requirement is every day each employee swipe the card several times i want to calculate first and last time of each...
View Articlehow to splitup the insert and update trigger in sqlserver?
My table is [employee]=name, emaili writing a trigger for this table.the conditions are1. If same employee name already existed is inserted means it won't accepted it.2. if email id already present...
View Article