switch to current database in SP procedure
Use master go create proc sp_TableCount as select count(*) TableCount from sys.tables where type_desc='USER_TABLE' GO use master exec sp_TableCount use test exec sp_TableCount you always get the...
View ArticleRAISEERROR not shown in Agent Job Log File Viewer
I use a RAISEERROR for a critical error in a CATCH. When the Job is run, it does fail but it gives the following message. How do i get my @Note to show in the Log File Viewer? Also, where is the log...
View ArticleHow can I see the commit time stamp for a transaction?
I’m looking to see if there is any way to tell, through a select, when a transaction was committed? I know you can get the transaction id by selecting the sys.dm_tran_current_transaction within a...
View ArticleHi Shanky , pls help out regading Profiler Trace issue ?
Hi Shanky, Pls help out . Regadng Profiler Trace . Thanks Vijay
View ArticleScript to rename all views in a database
Hi guys,Does anyone has a script in handy to rename all the existing views in a database .Thanks in advance
View ArticleStored procedure with ORDER BY and results to DataTable
I Don't need the result as a bound data for what I'm needing to do here.I have a datatable created by using a SQL stored procedure, and am using the code below to verify Product data. The stored...
View ArticleData Validation
I have several data validation rules i would like to apply to a stored procedure.For example If (select count(*) from table where (namel is not null or namel <> '') and (namef is null or namef =...
View Articlehow to change the default SQL Time zone to GMT -03:00
Hi all,when I use the query select getdate() I have the correct time, when I use the query select getutcdate(), the result is 2 hours more thant current time in Brazil.How to change the time zone on...
View ArticleNeed assistance with stored procedure
Hello - I would like to ask for some assistance or examples of similar queries to get started on a stored procedure that I need to create.I have developed an application for a repair floor that tracks...
View ArticleHow do update only the column that was updated?
hi friends, I have the following table structure of an Employee tableColumn Name type ============================= EmpID int EmpFirstName char(20) EmpLastName char(20) DOB Datetime AddressL1 char(100)...
View Articleshredding a table value returned from a udf
Hi. We run 2012 enterprise. If I return a table from a udf, and wish to select from it joining on perhaps the pk returned by the query from which the udf was called, thus generating a one to many...
View ArticlePrioritize values for same column query
Hi all:SQL08-I am having a hard time wrapping my head around how to solve this issue. I have some temp tables that are created in a proc from a series of queries that match up a customer to an order...
View ArticlePIVOT Rows to Columns based on dates with uneven amounts of rows and columns
I have looked through TechNet and SQL Server Central for a good way to pivot a difficult table. So far, the many different approaches have failed and I need a fresh perspective and help with the code.I...
View ArticleDBCC SHRINKFILE: Page could not be moved because it is a work table page.
tempdb is auto grown to max size and when i try to shrink below is the error its throwing can anyone help on this DBCC SHRINKFILE: Page could not be moved because it is a work table page.i try to clear...
View ArticleInsert Auto Incremented Values in Primary Key Field
Hi ALL ,I have a customer table with 3 fields CustomerID , Customer First Name and Customer Last Name .It already contains some data the Customer ID is a primary key and i need to insert some records...
View ArticleComparing Current and Previous record values based on compound identifier
I am trying to compare the current and previous record values of a set of records based on a compound identifier. This is a learning thing. I am just snapshotting configuration data into the...
View Articleany improvements in how verbose rank function is in 2012?
Hi. Has there been any improvement in the 2012 rank function syntax? Our queries are often twice as long as anybody wants to look at when most of the columns are used in the partition by clause and...
View ArticleUnion multiple tables dynamically based on lookuptable
Hi All,I have few table in my DB named info_1,info_2,info_3,info_4 and there is lookuptable named main_info.Main_info table containsID Startdate EndDate1 12/16/2013-00:00...
View ArticleLoop through month and year till date while using a merge statement
Hello Guys,I have 2 tables with the following datas in them:-CompanyCompanyId CompanyName1 Company12 Company23 Company3EmployeesEmployeeId EmployeeName...
View ArticleQuery a table
AccountID ContactName ContactCity ReachByPhone LastContactDate DecisionType001234xx Sean Chicago Yes...
View Article