probably an easy way to do this using DISTINCT
Hi I am trying to create a stored procedure (SQL query) that returns all columns of a table but only want the rows that are DISTINCT for one column only. That is I have a column TESTINT with integers...
View ArticleT-SQL script to import data from XML file to table?
Hi there,I've below data export/import requirement from XML to SQL Server table (and vice-versa).SOURCE (Export)Below is my query to export data into plain text file [no header in XML file, of...
View ArticleAPPLY in sql server
Hi, Can anyone help me to understand APPLY in sql server? can you please give me the example of what was the previously used approach (old approach ) and how APPLY can be replaced in place of the old...
View ArticleOne Row into multiple Column
CREATE TABLE #ids (empid VARCHAR(200)) INSERT INTO #ids SELECT '100,200,300,400' INSERT INTO #ids SELECT '1100,1200,1300,1400' I am trying to get output following formatID_1 ID_2 ID_3 ID_4100...
View Articlecreate role
I need to create roles : Roles need to be assigned to users to let them1. have write access to some tables2. have write access to store procedurehave hundred tables like dbo.abc_XXX_XXX. Need to give...
View Articlet sql query urgent pls
hi ,i have data like thiscola colb colc123 12 a123 12 b123 12 a124 12 d124 12 fwe have to loop throuhj all the values associated with colc for each cola and colb, if all the values are not in (a and...
View Articlefunction that generates a date without casts and concatenations
Hi. Is there a function in sql 2012 like the one in dax where Fx(datepart1,datepart2,datepart3) generates a date? I think datepart1 is year, 2 is month and 3 is day but I may have that backward.
View ArticleActing user = none OR null OR anonynous OR username$ OR localservice?
Greetings,We have a SIEM solution that correlates events from several Windows servers (2003 & 2008).Many events from different servers have in the "Acting user" field these users:none, null, nobody...
View ArticleCan a list of columns be used with this?
I'm curious if there is a way to pass in a list of column names and possibly table names too instead of just using one of each in the code below. Thanks in advance for any help!IF EXISTS(select * from...
View ArticleImplimenting SCD Type 2 using SQL Merge
Hello , I'm working on implimenting SCD type 2 to keep track of changes in dim_A with fields asTable A VQ_dim_Id , VQ_Name, Contact_Type , Contact_Type, Center_Node_Id , Sed_id , Eed_Id , Insert_date,...
View ArticleSorting Issue
Below is the result set that I am currently displaying Order_byCountryCapitalContinent8United StatesWashingtonNorth America20AustraliaCanberraAustralia5RussiaMoscowEurope77CanadaOttawaNorth...
View ArticleSub Query question
I'm working on a query that can probably be done by a simple subquery but I am struggling with getting the results. I am working a dataset that contains information about student's Major and Minor....
View ArticleGenerete Count of Sales Week by Week
I am running this script to generate a SQL Calender. I then want to join the calendar to my database and get a week by week count of Items Sold by week. My calendar generates no issue, but my Select...
View ArticleSumming a field if another field = scrap
I'm working on a SSRS report where I need to sum a field if another field=scrap. I have multiple fields with 2 parameters and a sum on 1 field already in this report. I have tried to make it work a...
View ArticleHow to select a data slice for a specific date from a SQL SERVER database...
The scenario is as following,All tables in the database has a Date column named EffectiveDate.Data is imported into the database using a logic which detects and inserts changed records only.Let us...
View Articleconvert non-asni sql to ansi sql?
Hi,I tried converting this using Query Editor but it rejected it.select LDate, b.Book, a.Type, a.Cusip, Ticker,Description, a.BankCode FROM dbo.SL_LPositions a,dbo.SL_LBankDTC...
View ArticleHow to make calculated column with values based from result of substring search
Hi!I've kind of painted myself into a corner. I have a table containingSELECT [DepositID] ,[OrderTicket] ,[DepositTime] ,[OrderTypeNumber] ,[OrderProfit] ,[OrderComment]...
View ArticleNOEXPAND Required in 2012 Enterprise
SQL Server 2012 Enterprise, build 11.0.2332.0. I've created a view that joins two tables, and has a computed column that includes components from both underlying tables. I've created a unique clustered...
View ArticleHow to calculate totals based on year (date) and comparing othe columns in...
Hello Good Evening, Could you please help me herehow to write condition for self table year records, such 2012 name and acctno match with 2013 name and acctno then total, provided below,create table...
View ArticleDate Filed Query
Hi,I have a database view which as a field : SentDate . In the view this field concatenates two fields from the base tables :DATEADD(D, 0, DATEDIFF(D, 0, d.actualdate))+d5.TimeFullactualdate is a...
View Article