Pass table variable to exec SQL Server
I am trying to write this stored procedure but I have trouble passing result of temp table (or table variable) to EXEC(@query) task:I also used table variable (see commented area) but not luck.I want...
View Articlequery compare date
I have a table, in each row, I have an CaseID, MTDThresholdDate, and YTDThresholdDateBoth of the date could be null, I would like to return what is the earlier date or smaller date.If either of them is...
View ArticleSQL Transpose the data
Hello guys,I am the newbie in this field so I really appreciate your help.As you can see from the attached file, my data currently looks like in the tab "Original data"And now I need some query to...
View Articleunable to change(update) the column value in SQL server Database
Hi,I have a table with many columns . I can insert the records in this table but cannot update few fields. It does not throw any error and message is "1 row updated". When I check the fields it remain...
View ArticleGroup multiple Rows into 1 string based on ID field
Hello,I am trying to group multiple Rows into 1 string based on ID field. Here is my sample code:CREATE TABLE #MyLocs (RegionID int, Loc varchar(10))INSERT INTO #MyLocs (RegionID, Loc) VALUES (1,...
View ArticleQuery Stuck causing Locks, but I see SP:StmtCompleted in SQL Profiler
Hi,I am experiencing an lock issue.The head blocker query is the following:INSERT INTO DIMENSIONHIERARCHYLEVEL...
View ArticleStored Proc Execution does not finish before next line excutes
I have a stored procedure that drops temp tables using dynamic sql. Immediately following that stored procedure is a CREATE TABLE for the temp table and then a INSERT into that temp table but I am...
View ArticlePAGE BREAK AFTER EACH GROUP ORDER BY
Dear All,I would like to get query with page break which after each group(preffered_name) results end, my sample code given below which gives without page break ..SELECT preffered_name ,ci.person_num,...
View ArticleRecursive query with two parents
I am currently struggling with a query to recurse up/down a tree. In real life we have a junction table with two FKs pointing to the parent. Both Id and Parent Id are not nullable. Below is an example...
View ArticleTotal Sum exclude from condition.
experts, i am trying to calculate Overtime hours . we have got employee who has Friday and Saturday holidays. so mentioned here in table column Friday , saturday value 1.i need to exclude the dutyhours...
View ArticleHow to select record that exist in other table
I have two tables [quote]CREATE TABLE [dbo].[StatusAudit]( [RowID] [int] IDENTITY(1,1) NOT NULL primary Key, [AccountID] [varchar](20) NOT NULL, [Status] [int] NOT NULL, [AuditDte] [datetime] NOT...
View Article|HELP| how create four part name to oracle?
heyi have link server to oracle from mssql.i want to update or insert with four part.1. how can i do it? 2. i read somewhere recommend to create views from oracle about the table i want thanks
View Articlecreating a sequence of number starting or each group of ID
I have 3 source table and have to union them all source 1:Id name car 1 aaa BMW 1 aaa Porche 1 aaa Nissan2 bbb Nissan2 bbb Hondasource 2:Id name car 1 aaa Camry source 3:Id name car 1 aaa Honda 1 aaa...
View ArticleCompleting Fixed Sets With Another Table
Hi,I'm having some trouble finding a solution to a problem, its been a few hours now and I think I just completely loose track of what I'm doing and ended up a few times bashing and mix matching...
View ArticleConverting time from datime into INT
declare @dte datetime Select @dte = GETDATE()@dte = 2016-10-31 11:42:51.920Is it possible to convert Time (11:42:51.920) into an INT so that it looks like 114257 ?
View ArticleRedshift Script
Hi I am using a script to get details about database name, schema name, table name, row count and size of each table in GB. I would like to add one extra column '% of Disk Utilization' to the table...
View ArticleUpdate a 3 column table from a single column
Wasn't sure how to word the title :)I'm working on a method to take user input to update a (target) table named UDFTemp. With some help in a different thread I think I have merge working when I use the...
View ArticleMERGE only when not null
I have a target and a source table where I want to update the target from the source. I have one non-nullable key field, and 3 data fields UDF1,UDF2, and UDF3.I get updates provided to me which list...
View ArticleTotal by Group.
Dear All,I am trying to bring the group total .below my query,[code="sql"]WITH Prep AS(SELECT preffered_name as Department ,email_address1 as subdepartment,friday,saturday,government_num as...
View ArticleMerge two tables and insert/update respectively
I have two tables and I have to merge the records.source:ID seq name designation company001 1 aaa Developer YYY001 2 aaa lead yyy002 1 mmm consultant bbb003 1 ppp developer yyy003 2 ppp lead yyy003 3...
View Article