sql-server-2008-r2

split function comma separator four columns SQL Server

喜欢而已 提交于 2019-12-13 04:51:47
问题 Team, i have another scenario, i need to split 4 columns and also 8 columns split, i changed the beginning code declare @numCols int = 4 i tried to change the final join statement, not able to achieve, Can you help on this. i could not able to join the single join statement at the end of the function declare @String varchar(max) set @String='sunday,9,meals,EYR,sunday,9,meals,USD,monday,9,meals,USD,friday,9,meals,USD' begin declare @numCols int = 4 declare @itr int = 0 declare @SplittedValues

Can I make this JOIN using OR faster without using unions?

家住魔仙堡 提交于 2019-12-13 04:48:08
问题 In SQL Server 2008 R2, is there a way to use some hints to force this query, which uses OR in a join, to run as fast as the below one, which replaces the OR with Unions? Slow query: select <stuff> from UPCs u JOIN Ingredients i on (u.UPCID = i.UPCID) or ( u.CategoryID = i.CategoryID and u.Quality = i.Quality) or (u.ManufacturerID = i.ManufacturerID and u.Quality = i.Quality) Faster query doing the same thing, but applying the criteria separately and concatenating the results with unions:

How to implement user impersonation in reporting services?

旧巷老猫 提交于 2019-12-13 04:35:44
问题 Software involved in this question is: SQL Server Reporting Services 2008 R2 SQL Server Analysis Services 2008 R2 SQL Server 2008 R2 Database Engine ASP.NET 4.5 Web Forms ReportViewer component We have several dozen reports. Some reports use T-SQL queries to our Data Warehouse database and some use MDX queries to our SSAS Cube. Active Directory Security Groups secure which reports a user can access on the Report Server. We additionally have made SSAS Roles that have Dimension Permissions on

How to get value by dynamic field Name using sql select query

做~自己de王妃 提交于 2019-12-13 04:07:28
问题 I am passing dynamic column name base that column name to get the value and below i my table Table_CandidateInfo Id Name Age City 1 Mazhar 30 Gulbarga 20 Khan 29 Bidar Example1 Declare @ColumnName varchar(100), @Id int set @ColumnName='Age' set @Id=20 select * from Table_CandidateInfo where ID=@Id and I am not able to pass ColumnName with and query because column name is dynamic pass by code. My output should be 29 Example2: If my @ColumnName='City' and @Id=20 then output should be like below

Update one by one records using loop in SQL Server

大憨熊 提交于 2019-12-13 03:34:40
问题 I have Sector ID, need to update sector name and sector short name as 'Sector 1' and 'Sector 1' for each sector id respectively using loop. How can I achieve this? SectorID SectorName SectorShortName --------------------------------------- 1 METALS METAL 2 FINANCIAL SERVICES FINAN 3 IT IT 4 SERVICES SERVI 5 PHARMA PHARM 6 CHEMICALS CHEMI 7 TEXTILES TEXTI 8 ENERGY ENERG 9 INDUSTRIAL MANUFACTURING INDUS 10 CEMENT & CEMENT PRODUCTS CEMEN 11 CONSUMER GOODS CONSU 12 CONSTRUCTION CONST 13 TELECOM

encode and decode base64 excpetion storing to sql server 2008 r2

我是研究僧i 提交于 2019-12-13 03:24:43
问题 I have an android client, I want to send image from my android to my server, i convert the image to byte array, then they byte array to base64, i send the base64 string to server, i decode it in the server then stored it in my sql server 2008 r2. my problem I can't store the string to my database then retrieve it correctly, I didn't get any exception and I get result but it seems it is the wrong result. i conclude that by doing this. 1- i send the base64 from android to server and saved the

How to insert bulk of column data to temp table?

烈酒焚心 提交于 2019-12-13 02:58:45
问题 I need to insert 13 columns of data in a row, and the data is stored in a single variable and every part of data is separated by comma. declare @cldt varchar(max)="SINDA,--,--,--,--,--,--,--,--,30.00,--,--,--"; I have the following temp table declare @TempTab table ( idx int identity(1,1), Component varchar(200), Month1 varchar(max), Month2 varchar(max), Month3 varchar(max), Month4 varchar(max), Month5 varchar(max), Month6 varchar(max), Month7 varchar(max), Month8 varchar(max), Month9 varchar

Dynamic select statement

本秂侑毒 提交于 2019-12-13 02:57:47
问题 We have a table in the database and this table has a column called 'fieldName'. In fieldName is a name of a column in another table. Basically this is part of a UI where a user can add a question to a form and when that happens we store that information in fieldName and then create a custom table with a column name that will match one field name. What I want to do is generate a dynamic SQL statement to get all the fieldNames and build that into a SQL statement. So far I have this: DECLARE

Counting number of rows grouped by date and hour

半世苍凉 提交于 2019-12-13 02:57:36
问题 I am tracking customer store entry data in Microsoft SQL Server 2008 R2 that looks something like this: DoorID DateTimeStamp EntryType 1 2013-09-02 09:01:16.000 IN 1 2013-09-02 09:04:09.000 IN 1 2013-09-02 10:19:29.000 IN 1 2013-09-02 10:19:30.000 IN 1 2013-09-02 10:19:32.000 OUT 1 2013-09-02 10:26:36.000 IN 1 2013-09-02 10:26:40.000 OUT I don't want to count the OUT rows, just IN . I believe that it needs to be grouped on Date , and DoorID , then get the hours totals. I would like it to come

I need all the employee under a supervisor

佐手、 提交于 2019-12-13 02:54:07
问题 i have a below described situation EmpID Name SupervisorID 1 A 9 2 B 8 3 C 1 4 D 3 I need all the employees under supervisor ID 1 Here EmployeeID 3 is under 1 i need 4 is is also under 3 Following output is required. EmpID Name SupervisorID 3 C 1 4 D 3 回答1: You need to Use Recursive CTE for this.Try this, With CTE as ( select EmpID,Name,SupervisorID from Emp where SupervisorID =1 Union All select a.EmpID,a.Name,a.SupervisorID from Emp as a inner join CTE b on a.SupervisorID= b.EmpID ) select