Validate each parent intermediary is also a parent to itself?
I have a table for which I want to validate where each parent intermediary is also a parent to itself. How to write query to validate this?COLUMN DATATYPE DESCRIPTION IntermediaryPK int SourceSystemID...
View ArticleCROSS APPLY a FREETEXTTABLE
table1 has a full text index. I want to run multiple freetexttable searches against it in a single query, but the two attempts i have fail. any help would be appreciated, thanks!CREATEFUNCTION...
View ArticleCreating new row in multiple tables for every specific type of existing row
As a beginner, I am looking for assistance on trying to create an order for every time another order appears. I have 3 order types in the table dbo.OrderType with columns OrderTypeID,...
View ArticleTrouble with query to aggregate values for filtering... do i need more sql...
I am trying to take a table that is used to filter values based on some criteria.For one [FilterID] it is easy... But when I want to concatenate filters, i am having trouble getting the rows/colums,...
View ArticleRegular Expression
oracle query - select LTRIM (REGEXP_SUBSTR ('\' || file_path, '\\[^\]*', 1, 7), '\') from table1 please provide eqvivalent query to extract...
View ArticleSelect Statement 3 tables, and Sum of one column
First let me say I have never taken any classes on sql. We just started supporting a new POS and it uses a access database, I am just learning this as I go. This is the statement I currently...
View Articlehow to get 5 min data from SQL data base
I have a data records for different pits for each 10 seconds. It is a bulky dataset. I just need to get the data from each 5 min for all pits. How could i write query in SQL for...
View ArticleMake sure auto-update of statistics is turned on?
Reference:SQL Server Performance-The Crib SheetI am in favor of having this feature off and statistics updated on schedule preferably nightly (off hours). What is your take on this important...
View ArticleHelp with Except clause
I have a source database dbtest02 with a table called article with the following dataid type cost001 1 40 002 2 34 003 7...
View Articleperformance
SELECT Hits.orgId, OrgTypes.Title, isnull(SUM(Hits.Hits),0) AS TotalHits, (SELECT SUM(Hits) AS Expr1 FROM orgHits...
View ArticleInsert Query
Hi frnds i want to insert to data into database asi have table as shown below with Table Name as T_MonthlyDays (i.e., from 01-31 days)01020304050607080910111213141516171819202122232425262728293031and i...
View Articlelanguage from latin to englsih in midde of code
Hi , I have a table from Client with latin language , i need traslation from latin to english for only one columnis it possible??Thanks in advance for replies:)
View ArticleCopy all tables with names begins with a given string
Hi, Did anyone come across to create a script to Copy all tables with names begins with a given string, assume is 'AA', from Database A to Database B within the same sql server? For instance, Table...
View ArticleSQL SELECT * FROM OPENROWSET with Variable
I am trying to pass a variable into a SELECT statement in OPENROWSET but I keep getting an error `DECLARE @dDateTIME DATE SET @dDateTIME = (SELECT SalesDate FROM dbo.SalesDate) INSERT INTO...
View ArticleDoes LIKE support (or can you code for) an optional character in a string?
I'm doing some IIS log file analysis and trying to group by referrer. This is a challenge since you can have multiple prefixes for the same domain:SELECT CASE WHEN Referrer LIKE...
View ArticleIn Organisation Hierarchy want to know if more then one sales rep
Hi All,I have this tableSELECT dbo.org_tree.org_id,dbo.org_tree.parent_id,dbo.org_tree.isleaf,dbo.org.company_name descendent_count ancestor_count...
View Articlexp_cmdshell
Hi,I'm now having the same problem like the following link and can anyone tell me that the way from Vidar is to grant the use of "xp_cmdshell" to that database...
View Articleinformation_schema.columns slowness
Hi The following select query taking around 50ms and its too costly, in my application i will call the same select statement in many times.SELECT COUNT(1) FROM INFORMATION.SCHEMA.COLUMNS WHERE...
View ArticleUpgrading to 2012 performance problem
Hi Im running a piece of code on a VM which takes just 1 second on our new 2012 box it takes 15 seconds.The execution plan is exactly the same, data is cached so it is all running in memory. Query is...
View ArticleHow to get the table name in the trigger definition without hard coding.
CREATE TRIGGER db.mytablenameAFTER UPDATE,INSERTAS INSERT INTO table1(col1) SELECT InsRec.col1 FROM INSERTED Ins --Below i am calling one sp for which i have to pass the table name...
View Article