Row Over Partition
Row Over partition escapes me.I wrote this:Select [COMPOSITE_PART],[CREATED_DATE],HTS_NUMBERFrom(Select ROW_NUMBER() over (Partition by .Created_Date<
View ArticleSQL to Excel : Using a SQL Table with Report Columns
This is a SQL to Excel question. We have a new SQL table with report columns and the position that they are used, that are related to columns used in Excel report. For instance if using Excel report...
View ArticlePivot Row to Columns
I have a table "tblPerson" that only has three columns hder, hderOrder and key. The hderOrder is the order that the hder, This table is column header information only and the order of the columns....
View ArticleQuery with Where clause + 3 OR clauses not working
after 40 minutes, none of the three conditions were returned in my results . . . and i had to stop the query . . .Where(H.Importer = N'FORD'AND H.Entry_Summary_Date >= '12/1/2017'AND...
View ArticleDynamic Columns as parameter in where clause
Hi All, I have query which has 20 columns along with alias names for the column. The plan is to have two parameters one is for where clause. This where clause will have something like ‘where...
View ArticleRestore Database from folder
I want to restore databases residing in folder say "D:\Backups\". This folder contains many set of db backup.I would want to do them automatically on my test server using "With MOVE" option where...
View ArticleLookup Transformation in SSIS
IN OLEDB Source I've something like Select ContactID, NameFROM dbo.TableA IN Lookup Transformation I need to pull only those ContactID's I'm writing something like thisSelect * FROM dbo.TableBwhere Co
View ArticleStored procedures from Access in MS SQL Server
Hi Guys,In Access i have Query where I am using textboxes fields from form:[quote]SELECT tbl_Slownik.Slownik_ID, tbl_Slownik.PESEL, tbl_Slownik.Person_ID, tbl_Slownik.Nazwisko_imie, tbl_Slownik.
View ArticleSearching a comma delimited string using wildcard multiple values
Hello all,I wasn't sure where exactly to create this question since the ultimate product is going into an SSRS report, but I'm having trouble writing the SQL query. I'm hoping someone out there will...
View ArticleAdding SSDT BI Templates in Visual Studio
I have a new laptop with Visual Studio 2015 Enterprise and SQL Server 2016 CTP 3.1 installed on it. I want to develop SSIS & SSRS projects using this setup, but I am having a hard time getting the...
View ArticleView query was fast with literal in WHERE clause, but super-slow using a...
I would like to share my experience recently, in the hope that it helps someone else or that others can suggest better solution options.I had a view that returns table-information within 10
View ArticleIf an INSERT fails, does the sql that follows still run? (is my code...
We have a stored procedure as below, which inserts a record, then checks @@ROWCOUNT to see if it was successful and throw an error if it returned 0. Is the THROW statement unreachable? I cannot think...
View ArticleUPDATE() function in a trigger
I have a database environment to support that features instead-of triggers on views (shudder!!). They work but are quite inefficient and I cannot change the architecture at this point to eliminate...
View ArticleNULL quandry
I have a situation where I'm trying to determine if a value has changed. I expected to be able to determine easier if the record had NOT changed by doing the following:[code language="sql"]WHERE NOT ((@O
View ArticleGrouping records with dynamic groups for report
Hello All,I'm not sure what is the best what to do this. I need to create groups for banding on a report. The groups are dynamic and are always changing. Here is the criteria for the groups.
View ArticleHow do I get the user login information from plan cache?
I need to show Userid, numberofQueries they ran on the day and the averageruntime of the query in seconds...I tried below and it's not working...It just gives me same result...Essentially, i need this...
View ArticleIssue with IS NOT NULL in a join
If I use this:[code language="sql"]LEFT JOIN[TSI].[ZATS_BROKER_FEED] Z on L.Part_Num = Z.Composite_part and Z.[SUB_ORG] = 'FORD' and Z.created_date > Getdate() - 400[/code]I get 7
View ArticleStored Procedure Dynamic SQL using sp_executesql Not working
I can successfully run a Stored Procedure (SP) that uses dynamic SQL and Exec sp_executesql in my local environment. But when I run the same SP in our dev environment I get "default schema does not...
View Articledm_sql_referenced_entities view-mediated updates
Hi SSC,Unfortunately I think I probably know the answer, but figured I'd ask anyway. I've been writing a proc to identify the proc(s) which update a given table. I can do this by using...
View ArticleDifferential Restore Question
SQL 2014My colleagues and I have been debating whether a Differential or Transactional backup (.bak, .trn) can be restored without first restoring a full backup with NORECOVERY.Here is our scenario...
View Article