Execute Stored Procedure in a batch file using a result from Query as a...
Hi !I have a stored procedure in my database. It is an Insert or Update Procedure from Temporary Table to Base Table:Temp_Item_Table and B_Item_TableMy Stored Procedure is Procedure_Upsert_Item in...
View ArticleSQL Query to predict column
Hello Team, we are planning to do a task i..e to identify the tables which have column like firstname, lastname etcThis i can achieve by writing sql query but there are tables which won't have any...
View ArticleHow to dynamically create multiple Pivot join
Is it possible for me to do the following in dynamic pivot? The code below basically in the first select put the 'result' value for each month into the 'Value' field in the temp table #ValueBucket....
View ArticleUpdate causing lots of rows to be affected
My update looks like this. I have a clustered index on adid on the txtad table, so I thought this would affect only a single row. Instead it takes a while to come back and gives the message...
View Articlequery results as string
Hi,We are using SQL Server 2005 I have a select query like this: Select distinct(column1) From table1 t1 WHERE t1.status in ('AAA', 'DDDD') except select column1 from @tmptableThe results are:Quat123...
View ArticleThe ltrim function requires 1 argument(s)
Hi All,I got below error while using command -- LTRIM (MEG,'0')error: The ltrim function requires 1 argument(s).i want to remove 7 zeros in front of the number.example:before: 00000006787after:...
View ArticleWHERE CONDITION in UNIX timestamp
Hi all, I am stored a datetime value in the column field.The datetime value is converted into unix timestamp and stored into a bigint column.Now i want to query the details by where condition in that...
View Articlestored procedure
Hi all,i was created a simple stored procedure like this..CREATE PROCEDURE sp_date @table varchar(50),@column varchar (20),@From int,@To intAS SELECT * FROM @tableWHERE @column BETWEEN...
View Articlemaxdop linked server question
Does anyone know how MAXDOP works when you have a linked server query? I have a linked server query that is reading a table on a remote server and inserting it into a table on the local server. Does...
View ArticleUse of various types of SQL Server Table Expressions
Hi, With regards to the 4 types of SQL Server 2012 table expressions, namely: 1) views 2) inline table valued function 3) derived table 4) common table expressions anyone can shed some real life...
View ArticleFORMAT Command with TIME Data Type
How can TIME data type be formatted? Thanks.DECLARE @t char(4) = '1600'; DECLARE @tm time = STUFF(@t,3,1,':'); SELECT @t, @tm, FORMAT(@tm, 'hh:mm:ss', 'en-US') -- 1600 16:00:00.0000000 NULLKalman...
View ArticleProblem getting single output row from many.
my query returns multiple rows. I am using Row_Number() to order them. I then select Row = 1, which should show me only the row that is first in the list. Instead, I'm getting 6 rows of output.My query...
View Articleproblem with write a query
Hi,i have to do a view but i have problem with query its all about asset.i have table with data as below, table name is assetaable ofc i`ve got about 10k rows in tableASSETID NAMEALIAS...
View ArticleImproving DELETE performance - SQL Server 2012
Hi,in a my stored procedure I need to use the DELETE statement, and I cannot use TRUNCATE TABLE, in order to deleting rows with a specific year. The table source has more tens of millions of rows and...
View ArticleExecution plan for index that doesn't actually exist
Hi All,I know how to compare execution plans using "USING (INDEX(1))" for a clustered index. I do this with another query to compare execution plans in the same screen. I seem to remember hearing...
View ArticleCorrect way to do update?
Hi I'm trying to accomplish the following update. What is the correct and most efficient way to do this?I want to update #tmp2 with the price in #tmpWhere the date in #tmp is equal to the date in #tmp2...
View ArticleHow to create dynamic where clause in Select statment
Hi everyone,We are using SQL Server 2008 R2 - Enterprise edition.What is the most efficient way to create dynamic 'where clause' for select statment.ThanksA.G
View ArticleT-SQL Code Structure - Review/Comment?
Hello,I'm still new to T-SQL and have hundreds of CHECK constraints that I need to create scripts for. I'm interested in comments from the more experienced folks out there as to the best way to...
View ArticleWrong Enconding on Select with Union
Hi there,I got multiple tables, all of the same structure, containing the same columns. The columns are allvarchar(250).Now I have a query, that connects all the tables via UNION ALL and selects a...
View Articleextracting valid mobile numbers
hi All,im trying to extract the valid mobile numbers with out any other charecters(*,/,+ etc..) only numeric 10 digited number.EX:*091234567890--output should be 91234567890...
View Article