Questions tagged [sql-server-2008-express]

25974 questions
1

votes
1

answer
33

Views

How to calculate the total logged time in a day?

How do I calculate the total amount number of hours spend inside in SQL? For instance, for this employee, the total amount of hours spent inside would 12-2=10. EmpID Enter/Exit Time 2999 Entry 06:00AM 2999 Exit 12:00PM 2999 Entry 01:00PM 2999 Exit 03:00PM 2999 Entry 04:0...
null
1

votes
3

answer
1.1k

Views

Product price comparison in sql

I have a table looks like given below query, I add products price in this table daily, with different sellers name : create table Product_Price ( id int, dt date, SellerName varchar(20), Product varchar(10), Price money ) insert into Product_Price values (1, '2012-01-16','Sears','AA', 32) insert int...
Vicky
1

votes
1

answer
777

Views

Search for column name in multiple databases on SQL Server

I need to find specific columns in many databases, located on the same SQL Server 2008. I have tried many solutions over the internet, but none worked for more than system databases. What is the best way to extend the search to look inside all databases on one server?
Alcor s
0

votes
1

answer
11

Views

Combine two columns data with first char of second column into one column leaving null values

I have a table like below: ------------------ | Scode | Ucode | ------------------- | qwei | we2 | | iu76 | oi | | ikhj | null | | null | ikj | ------------------- I want output like below ---------------------------- | Scode | ucode | Finalcode | -----------------------------...
Amitesh
1

votes
2

answer
59

Views

Calculate average of a row in SQL Server

I have the below table..the percent column is of type nvarchar Data Percent1 Percent2 Percent3 1 3% 4% 6% 2 6% 8% 7% 3 8% 6% 8% I have to calculate the Avg per line so I get results like Data Avg 1 4.33% I was trying to convert the %column in...
SP1
1

votes
2

answer
60

Views

Convert MonthName-Year to Year-MonthNumber

I have a custom date string in SQL. I need to convert the date into custom format. Below is the example for it. SQL Input : 'January-2019' (Month Name-Year format) Output : '201901' (Year-Month Number format, Month Number must be two digit)
Rupesh
1

votes
0

answer
24

Views

SSIS - Write a log in existing package

I would like to include a log to check the DB source in existing package to track DB source details in different environments. This is existing package and I am totally new to SSIS. I am not sure how to implement in SSIS package. Is there any built in functionality available in SSIS 2008? It would...
Ask_SO
1

votes
1

answer
471

Views

create cte multiple times and drop cte [closed]

I am using a cte in stored procedure. I have to use it multiple times ie populate cte for different ids how can I drop or remove current cte thanks ;WITH PAYOUT_CTE(REGNKEY, REGNTPE) AS ( SELECT REG_KEY, 'Parent' FROM ML_MSTR_REGN A (NOLOCK) WHERE A.COMP_NO = @COMP_NO AND A.REG_KEY = @CUR_...
GL SOFT INDIA
0

votes
0

answer
4

Views

Printing Dynamic Sql with Parameter Values

I want to print the SQL Query which is used in the below stored procedure with parameter values.Currently it is printing the SQL Query without parameter values substitution while executing the stored procedure.It is printing the the parameters as it is(for example AND TP.F_LANGUAGE = @LANGUAGE) CRE...
Ram
1

votes
0

answer
34

Views

Can upgrading Windows Server R2 Standard to Windows Server R2 Enterprise affect configurations of installed SQL Server 2008 Management Studio?

I try searching anywhere in other sites and I can't find a good answer to my question maybe I just search here and find the right answer. In my company that I employed with, we use Windows Server R2 Standard and it was live and functional. Our team wants to upgrade to Windows R2 Enterprise My quest...
1

votes
1

answer
237

Views

WSUS SQL Query - Sort by ArrivalDate

I was given a SQL script to run by our Global IT group to generate the monthly WSUS reports they want. However, it returns everything in WSUS, not just the past months information. I am looking for assistance with modifying the script I was given to filter out all of the previous dates. This report...
Stephen Parker
1

votes
2

answer
66

Views

SQL Server 2008 R2 old version of stored procedure comes back

I have a stored procedure in my production environment that was originally written by someone that didn't have enough time to design it correctly. It was written with 9 or more joins to a database across a linked server connection. The stored procedure was taking more than an hour to run. About a...
RemonsterGrrr
1

votes
0

answer
122

Views

How can enabling CLR in one instance break something in another?

So there's this company that has been working with SQL Server 2008 and for a project i needed some new features so i installed SQL Server 2012 express (both on the same server). Months later, i had to use CLR for some complex operation so i enabled it there (2012): sp_configure 'clr enabled', 1 Ever...
dpaladin
1

votes
2

answer
36

Views

Parsing a comma delimited column and transposing into rows [duplicate]

This question already has an answer here: Turning a Comma Separated string into individual rows 14 answers Suppose I have a table like this with an undetermined number of comma-delimited values in one column: thingID personID 1 123,234,345 2 456,567 and I want to get it into a...
Greg
1

votes
1

answer
43

Views

Combine 3 OUTER APPLY into 1

I have a select Query where I'm using 3 OUTER APPLY statements one the same table and the 1st condition is same for all and the rest is different. and I'm using it to get the SUM of the same field. Is there any way that I can Combine all these 3 into 1? Below is how I have Done so far : OUTER APPLY...
Jayasurya Satheesh
1

votes
0

answer
59

Views

Can't connect to Oracle server from my machine using Microsoft's SSMA for Oracle tool

I'm trying to connect to Oracle 9i database from my machine (Windows 7 x64) using Microsoft's tool SSMA for Oracle v7.6.0 but getting the following error : System.Data.OracleClient requires Oracle client software version 8.1.7 or greater. A quick search on the Internet shows that this error messa...
mounaim
1

votes
1

answer
105

Views

How can I find out date & time for executed query [closed]

I executed some SQL query and I closed the query and results window (editor: presumably in SSMS), but I cannot remember the date or time that I executed it. How can I know date & time for this executed query ?
M. Ezzat
1

votes
0

answer
81

Views

How to determine which columns to index in a SQL query

I have a program written in VB.NET with a SQL Server database, to manage my electric engines' system, where I have about 15000 records in my database till now and as I'm filling data more and more, my queries started to slow down exponentially. I decided to solve that issue by indexing, however I do...
Mohammad Fneish
1

votes
0

answer
56

Views

How to use datatable for SSRS Report in SSRS Class Library?

Hi I created a simple Class in SSRS solution. Public Class Class1 Dim table As DataTable = GetTable() Function GetTable() As DataTable ' Create new DataTable instance. Dim table As New DataTable ' Create four typed columns in the DataTable. table.Columns.Add('Dosage', GetType(Integer)) table.Column...
BobNoobGuy
1

votes
1

answer
38

Views

How to get sets of date divided by week on the basis of present date and First day of month

for example if today is 22 Jan ,then i want get the date set as (StartDate :16-Jan-2018 & EndDate:22-Jan-2018) and second date set is as (StartDate :9-Jan-2018 & EndDate:15-Jan-2018) and third date set as (StartDate :02-Jan-2018 & EndDate:08-Jan-2018) and last date set as (StartDate :1-Jan-20...
Jalaj Varshney
1

votes
1

answer
329

Views

Connecting UWP App to Remote SQL Server 2008 provider: TCP Provider, error: 0

System.Data.SqlClient.SqlException: 'A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The operation completed successfully)' I'm trying to connect to SQL Server 2008 R2 database with a UWP APP. Remote...
Lee
1

votes
1

answer
36

Views

If value is true update some columns, if not update anothers

i will try to explain my 'issue' i have two tables Table1 id parent_id name active 2008 10 name0 Y 200801 2008 child of name0 Y 200802 2008 child of name0 Y 201102 10434344 child of name0...
Carlos
1

votes
2

answer
53

Views

Need query to select min cost and max date

I have a table and values like this create table minmaxtest ( id int, mfg varchar(100), mfgid varchar(100), [Desc] varchar(100), po_date date, cost money ) insert into minmaxtest(id,mfg,mfgid,[Desc],po_date,cost) Values (1,'abc','123','catheter','09/30/15',9) insert into minmaxtest(id,mfg,mfgid,[D...
natwar lal
1

votes
0

answer
33

Views

Monthly and Yearly Report in one row

I have a table whose output is this i have written my query like this SELECT c.DivisionNameEn, a.LF_CompanyDivisionID, 0 as code, SUM(a.totInvoiceAmnt) AS Sales, 'Sales' Salesperson, sum(a.totInvoiceAmnt) as Sum , sum(a.totInvoiceAmnt) /sum(a.totInvoiceAmnt) *100 as MonthPercent , YEAR(a.Trans...
Mohammed Asadullah
1

votes
0

answer
209

Views

SSIS package connection is not working in sql server agent

I'm trying to connect to a AS/400 system with a IBM DB2 for i5/OS IBMDA400 OLE DB Provider as a connector. I want to write data to a table in the AS/400 system and read data from the same location. So I build a package that writes data from a sql server db on a SQL Server 2008r2 to the AS/400 syste...
chr1s84
1

votes
0

answer
109

Views

SSDT Compare operation with SQLCmd variables in SQL Project

SSDT Compare I have just found does not recongize it's own SQLCMD variables. I have a SSDT SQL Project that I deploy to a DEV database. I want to compare the SSDT SQL Project to the DEV database after deploy. The problem is the SQLCMD variables in the project get flagged as differences by the compar...
user5855178
1

votes
0

answer
32

Views

Timestamp Field Incriminating

I have a table as such (with a timestamp and a varbinary) CREATE TABLE [dbo].[CASE] ( [CASE_ID] [int] IDENTITY(1,1) NOT NULL, [CASE_TITLE] [varchar](50) NOT NULL, [CASE_STATUS] [varchar](50) NOT NULL, [MODIFIED_TS] [timestamp] NOT NULL, [SYNCED_TS] [varbinary](8) NULL ) Then I add an item to it, and...
Bill Daugherty
1

votes
0

answer
27

Views

Use GROUP BY and ROW_NUMBER together in query

In my query I am using rownumber to have a partition on customer id but i want it grouped by emailaddress. Is there a way to do it? I have two tables, containing the following columns: Customers: EmailAddress,CustomerId Orders: OrderDate,CustomerId,OrderId,PaymentAmount select t.EmailAddress, COUNT(...
jsingh
1

votes
1

answer
57

Views

SQL How clarify a weird char in a string

I have grabbed from a file source a column that suppose to be a DATE not more longer than 8 chars in a NVARCHAR(50) staging field. Now when I try to cast it to DATE it fails because SQL is not able to apply the transformation. I tried to go deeper and understand what's going on and take a look the l...
Andres Urrego Angel
1

votes
0

answer
57

Views

SQL Server 2008 sa password expires automatically after some minutes

SQL Server 2008 was working fine last 2 months, but yesterday we taken Internet to system through second LAN port after that SQL Server 'sa' password is expiring automatically. Sometimes I get this error No process is on other end of the pipe' ERROR : 233 or sometimes login failed for user sa err...
Nikhil
1

votes
1

answer
167

Views

DB Collation different to Analysis Services Collation

I'm installing SQL Server 2016 and I need my DB collation to be backward compatible with previous Database setups. Therefore, I have selected SQL_Latin1_General_CP1_CI_AS. This is fine as there is an option to allow this (See below): However, when selecting Analysis Services, the option is not avail...
Justin
1

votes
1

answer
78

Views

query sql server - error when grouping fields

I have this query SELECT B.IdDepartment, B.IdParent, CASE WHEN B.IdParent = 3 THEN 'SANTO DOMINGO' WHEN B.IdParent = 4 THEN 'BAVARO' ELSE 'INACTIVOS' END AS Localidad, A.IdUser As Codigo, A.Name As Nombre, B.Description As Departamento, CONVERT(DATE,C.RecordTime,102) As Fecha, CASE WHEN (SELECT...
Frankenstainero
1

votes
3

answer
57

Views

SQL : Get last 3 month data (with only available data in the column), not from current month or today?

Anyone help me out on this scenario. I need to get a last 3 month data from particular column, which is not from current date but only from available date. Ex : I have one Table named Shop and column named OrderDate, In OrderDate i have only dates until 30-06-2017, but today's date is 07-02-2018. Fr...
Kapil
1

votes
0

answer
147

Views

How to connect php application to localdb on sqlsrv?

I'll send postcard to any clever quy letting me move forward with the following issues: It is visible for Toad and Microsoft SQL Server Management Studio Here is the code: $serverName = '(Local)\\Takdzwiedz_DB'; $db = 'eraz_v3_local'; $connectionInfo = array('Database' => '$db'); $conn = sqlsrv_conn...
Artur Kacprzak
1

votes
1

answer
29

Views

Add publisher in SQL Server 2008 R2

How are you guys ? I have SQL Server 2008 R2 and I am trying to add a publisher on my server but when I left click on 'Replication', I don’t see the option 'New Publication'. I am following a tutorial but I can’t follow it because I need to enable that option. Thanks so much
1

votes
0

answer
46

Views

Accessing SQL Server Compact from SSMS 2008 R2

I am using SQL Server 2008 R2 with SSMS, and I want to connect to SQL Server Compact (sdf files) but the option is disabled (greyed out). This is how it looks like: I also installed SQL Server Compact 3.5 SP 2 and their tools, see the first 2 items, but it stays greyed out: Who knows a solution?
1

votes
1

answer
57

Views

Multiple IF EXISTS statement

I have a stored procedure that sends daily report for 2 operational machines. I also show on report misfire count per machine but if 1 machine has 0 misfires and the other has more than 0 the Misfire report section will be skipped and not reported. First I want to check and see if any items exist fo...
DRUIDRUID
1

votes
2

answer
391

Views

How to update and insert a new record on when matched condition in SQL Server

I have written a stored procedure in SQL Server. Basically it tries to handle SCD2. Three things am trying to do: When not matched by target, insert the record When not matched by source, inactivate the active record(update) When matched, update the active record flag to N These 3 scenarios are bein...
Dex
1

votes
2

answer
50

Views

Name Resolution of TRUNCATE TABLE in SQL Server 2008 R2 vs SQL Server 2014

We experienced an error in our code that was executed in SQL Server 2014 which we do not encounter in SQL Server 2008 R2. Our code is like this: IF EXISTS ( SELECT 1 FROM master.dbo.sysdatabases WHERE name = N'WebDB' ) BEGIN TRUNCATE TABLE [WebDB].[dbo].[webtable] END The Truncate Table command wil...
Jason
1

votes
1

answer
136

Views

Store Procedure/Query running slow based on dates in Parameter?

I have a query (that I also made a stored procedure for). In the query, when I use 2017 dates ('2017-09-30' -> '2017-12-31') The query runs fast (1 sec). When I run this as store procedure with date parameters, the query takes forever to run (greater than 5 mins for the same data, partial results)....
ShaneW

View additional questions