Display all tables and its column from database if particular column value is...
I have a requirement in which I need to display certain columns from table in database, if1)- One of the column returns the value NULL within last 24 hours of data warehouse loadE:G;I have table test1,...
View Articleselect customers that have orders matching a specific list of products or more.
anyone know how I can select a list of customers that have orders with at least a specific list of products or more, but not with a partial list?e.g. Product Search List (is a table): 1 Oranges 2...
View Articlehow to create a function with dynamic sql or any better way to achieve this?
Hello, I have created below SQL query which works fine however when scalar function created ,it throws an error "Only functions and extended stored procedures can be executed from...
View ArticleHelp with like in sql
Hi all, I am having an issue with like statement with full text searchMy data : BEAN PEELER SQL STATEMENT: Select * from table where col1 like '%[^a-z]peeler[^a-z]%' doesn't give all the results...
View ArticleSubqueries
Hi everyoneCan you please tell me how to join below 2 queries using sub query or CTE.I get output separately for each query like thisBRANCH TOTAL_SHIPPEDABC 6789 BRANCH...
View ArticleHow to work on Data Analysis using Stored procedures
How to work on Data Analysis using Stored procedures any suggestions
View ArticleHow to find a value in all the columns of table?
I have to search a value: 20.281000 in all the columns of my table. Is there any way to search all the columns?
View ArticleHow to compare this week with last years week sales ?
Hi all,I have a table called Sales with two columns Date and UnitsSoldDate is of type smalldatetime and will have the date of the saleswhile UnitsSold is type int and will have the number of units...
View ArticleSQL Server 2008: How to convert table Columns as part of values in a...
Existing Database Table:DateTimeLogColAAColBBColCCColDD1/1/141296151/2/14864101/3/144325Can a View, as below, be created out of the Table above wherein all columnsexcept column DateTimeLog, i.e. ColAA,...
View ArticleT-SQL to get multiple rows into single row for the same ID group
Hi All,I have a table with 3 columns and my source data looks like..ID Name Role 1 Sam TP 1 Tom TP 1 John TL 2 Rosy TP 2 Deb TL...
View ArticleFilling gaps when calculate running total
Hello Friends,i have a script that calculate running total,but i have gaps between dates.i had some solutions to resolve this issue but it did not perform well.because my source table has over milllion...
View ArticleManagement Studio Query Execution Ignoring Batch GO Statements
Is it possible to run a script with several batches where one batch depends on an object that is created in a previous batch? I am getting the error "Invalid object name 'blah blah.' But this object is...
View ArticleINNER Join Takes High Cost
Below piece of code, INNER Join is used 2 times and its costing High on execution plan andtakes more than 2 min to complete. is there a way to reduce the inner joins to speed up the store proc.. Please...
View ArticleRepair SQL database that has been marked suspect
I woke up this morning to find my company's SQL database inaccessible and marked suspect. I have used various t-sql commands to bring it into Emergency mode. Now it is labelled...
View ArticleSeed data script generation
Dear All,I need to generate the Seed data from the existing table. If I need to generate all the data in the Table, I can use the SQL script generate wizard, but I need to generate the script which has...
View Articlecpu usage differ
Hi all,The Task manager shows the cpu usage is 98% but when i query via tsql.<<<SET NOCOUNT ON declare @ts_now bigint --SELECT @ts_now = cpu_ticks / convert(float, cpu_ticks_in_ms) from...
View ArticleError for creating a view, when I try to use a specific schema
Hi,I have a query which has some UNION ALL statements.select a, b, c, ad_spend from tbl aunion all select a, b, c, ad_spend from tbl bunion allselect a, b, c, ad_spend from tbl c where ad_spend >...
View Articletemp table scope within stored procedures
Hi,I want to build a main sproc that will contain a temp table with policy records. I then want to call a 2nd sproc from the main sproc, but i want to be able to use the temp table that was created in...
View ArticleChanging a text value in a column to a number, then using SUM to get the total.
SELECT TOP (100) PERCENT dbo.department.name, COUNT(dbo.Nurses.id) AS Expr1, dbo.Degrees.name AS Expr2, CASE dbo.Nurses.jobstatus WHEN 'FT' THEN 0.90 WHEN 'PT' THEN 0.60 WHEN 'PRN' THEN 0.30 END AS...
View Article