Quantcast
Channel: Forum Getting started with SQL Server
Viewing all 8979 articles
Browse latest View live

How to override Modified data from Remote database

$
0
0

recently i implemented link server with the sql server for link a Remote database and  according to i have create a local DB and some data tables into my local database from Remote Database, By now my requirement is recently modified data override to local database, i can use truncate table and again insert into same table from remote database, but what is a better option override modified data from remote database.

 

Error converting data type varchar to numeric.

$
0
0

Hi,

Here is my function

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[uf_getCamraTime](@camra_time decimal )
RETURNS decimal
AS
BEGIN

declare @num as decimal(10,2)
set @num=@camra_time
select @num=convert(varchar(10),floor(floor(@num/60)/60))+':'+convert(varchar(10),floor(@num/60)-(floor(floor(@num/60)/60))*60)+':'+convert(varchar(10),floor(@num-floor(@num/60)*60))

-- Return the result of the function
RETURN @num

END
GO

When I run it like [uf_getCamraTime] 53784.41 getting Error converting data type varchar to numeric.


Itsme

Who will be announced as the next SQL Server Guru? Read more about January 2019 competition!!

$
0
0


What is TechNet Guru Competition?

Each month the TechNet Wiki council organizes a contest of the best articles posted that month. This is your chance to be announced as MICROSOFT TECHNOLOGY GURU OF THE MONTH!

One winner in each category will be selected each month for glory and adoration by the MSDN/TechNet Ninjas and community as a whole. Winners will be announced in dedicated blog post that will be published in Microsoft Wiki Ninjas blog, a tweet from the Wiki Ninjas Twitter account, links will be published at Microsoft TNWiki group on Facebook, and other acknowledgement from the community will follow.

Some of our biggest community voices and many MVPs have passed through these halls on their way to fame and fortune.

If you have already made a contribution in the forums or gallery or you published a nice blog, then you can simply convert it into a shared wiki article, reference the original post, and register the article for the TechNet Guru Competition. The articles must be written in January 2019 and must be in English. However, the original blog or forum content can be from beforeJanuary 2019.

Come and see who is making waves in all your favorite technologies. Maybe it will be you!


Who can join the Competition?

Anyone who has basic knowledge and the desire to share the knowledge is welcome. Articles can appeal to beginners or discusse advanced topics. All you have to do is to add your article to TechNet Wiki from your own specialty category.


How can you win?

  1. Please copy/Write over your Microsoft technical solutions and revelations to TechNetWiki.
  2. Add a link to your new article on THIS WIKI COMPETITION PAGE (so we know you've contributed)
  3. (Optional but recommended) Add a link to your article at the TechNetWiki group on Facebook. The group is very active and people love to help, you can get feedback and even direct improvements in the article before the contest starts.

Do you have any question or want more information?

Feel free to ask any questions below, or Join us at the official MicrosoftTechNet Wiki groups on facebook. Read More about TechNet Guru Awards.

If you win, people will sing your praises online and your name will be raised as Guru of the Month.


PS: Above top banner came from Vimal Kalathil.


install sql server 2017

$
0
0

Hi,

I have a SQL server 2014 on my system. now I want to install SQL 2017. what is the best way to do this?!

1. uninstall the 2014 version and then install 2017.

2.upgrade the 2014 version to 2017?! (if I upgrade it, is there any problem?!)

Connection failed: SQLState:'01000' SQL Server Error:67 [Microsoft]ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). Connection failed: SQLState:'08001' SQL Server Error:17 [Microsoft]ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist o

$
0
0

Help,

setup a new sql server 2012 on a windows 2012r2 server to replace old sql server 2005 on an old windows server 2003 machine.  When i test the ODBC connection locally on the server it works fine, however when i try to connect via windows 7 client machine i get the following error:

Connection failed:
SQLState:'01000'
SQL Server Error:67
[Microsoft]ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
(Connect()).
Connection failed:
SQLState:'08001'
SQL Server Error:17
[Microsoft]ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied

I think it must be a permissions thing, I've turned off the firewall for now and still no difference, 've also made sure remote connection is enabled.  I can connect to the other sql server in studio manager on the new machine however, i can't go do the same in the old server, says:

cannot connect to hbfsqlpro1\hbfsqlpro1
Additonal information a network related or instance specifc error occured while establising a connection to SQL server.  The server was not found or was not accessible.  Verify that the instance name is correct and that SQL server is configured to allow remote connections. (provider:SQL Network Interfaces, error 26 - error locationg server/instance specified) (Microsoft SQL server)

the instance is def correct, as that is what i use to connect locally on the new machine and what it comes up on the studio manager on the new machine.  STarting to pull my hair out somewhat, i'm sure it's something really simple! 

Install SQL Server 2016 Express on Windows 10 Pro 64bit version 1809

$
0
0

Hello,

I have downloaded latest Windows 10 Pro 64 bit version 1809 via medai creation tool. After clean Windows installation, I am trying to install Microsoft SQL Server 2016 without success with following. Anyone have tried to install SQL 2016 on latest Win10 version 1809?

Microsoft SQL Server 2016 Setup
------------------------------

The following error has occurred:

Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.

For help, click: http://go.microsoft.com/fwlink?LinkID=20476&ProdName=Microsoft%20SQL%20Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=13.0.5026.0&EvtType=0xD15B4EB2%25400x4BDAF9BA%25401306%254026

Optimize query used to calculate invoice last month

$
0
0

I use the following query in order to calculate the invoice last month. how could I simplify it ?
SELECT
    T1.SNAP, SUM(T3.INVC)AS INV2FROM
    stg.sales AS T1 INNERJOIN(SELECTCONVERT(NVARCHAR(6), PERI)AS PERI,
         YEAR(SNAP)AS ANNE,
         MONTH(SNAP)AS MOISFROM
         stg.salesWHERE(DAY(SNAP)=1)UNIONSELECTCONVERT(NVARCHAR(6), DATEADD(MONTH,-2, MIN(SNAPDATE)),112)AS PERI,
         MIN(YEAR)AS ANNE,
         MIN(MONTH)AS MOISFROM
         dbo.SALES_Daily)AS T2 ON T2.ANNE = T1.ANNEE AND T2.MOIS = T1.MOIS  INNERJOIN
    csk.Data_Invc AS T3 ONCONVERT(NVARCHAR(6), T3.SNAP,112)= T2.PERIGROUPBY
    T1.SNAP

What is SYS User?

$
0
0

Hi everyone,

I have a user called sys within one of my databases, it has a red down arrow next to their username icon.

Do I need this sys user? 

If so how can I enable this user?

I'm using SSMS 2017

Thanks in advance.



absolute noob - question on linking flat files to SQL Server

$
0
0

Hi, I use MS Access at work but recently have been running into issues as the file size is now at the maximum 2gb.  I read about going to Sql Server, my work laptop has sql server 2014 and a I was playing around with a fake database.  I guess my intent for now is to house all the  large data tables there and link to MS Access where all my queries are.  Maybe eventually I would convert fully to SQL Server.  In Access, I have a lot of tables linked to text file data dumps from various IT data systems.  I just download and rename to the same file name each month.  Access always links to that name.   I was trying to do the same in SQL Server and I can only import as a flat file.  However, it's not a link, so I would have to go through the import wizard each time there is a change.   Is there an option to link to a flat file so the data table will always be updated? 

Thanks

Roger

T-SQL Running Total Query....

$
0
0

I'm trying to create a sql script/view that looks at a customers Cash Receipts and then identifies how the Payment should be applied to the customers oldest (by date) invoices.  I'm having 2 issues with the below query: 1) if the customer has more than 1 Cash Receipt they are not sequentially being applied/reducing the invoices in order and 2) the apply amount doesn't seem to be correct when the customer has either 2 payments or 2 open invoices.

This is what I'm currently getting as a result set:



Basically what I would want to happen is as follows:


WITH CTE AS (
SELECT
rownum = ROW_NUMBER() OVER (Partition by CR.CUSTNMBR order by INV.DOCDATE)
, CR.CUSTNMBR as Customer_Nbr, CR.DOCDATE as Apply_Date
, CR.DOCNUMBR as Source_Document_Nbr, CR.CHEKNMBR as Check_Nbr
, CR.CURTRXAM as Available_Apply_Amount
, INV.DOCNUMBR as Apply_to_Document_Nbr, INV.CURTRXAM
, INV.DOCDATE
, case when CR.CURTRXAM - sum(INV.CURTRXAM) OVER (Partition by CR.CUSTNMBR order by INV.DOCDATE, INV.DOCNUMBR) < 0 then 0 else CR.CURTRXAM - sum(INV.CURTRXAM) OVER (Partition by CR.CUSTNMBR order by INV.DOCDATE, INV.DOCNUMBR) end as AvailableBalance
, CR.BACHNUMB AS Batch_Id
From RM20101 CR (nolock)
       JOIN RM20101 INV (nolock) on CR.CUSTNMBR = INV.CUSTNMBR --AND CR.CURNCYID = INV.CURNCYID
Where LEFT(INV.TRXSORCE,4) = 'SLST'
AND INV.RMDTYPAL = 1 
AND INV.CURTRXAM <> 0
AND CR.CURTRXAM <> 0
AND CR.RMDTYPAL = 9


SELECT 
CTE.Customer_Nbr, CTE.Apply_Date, CTE.Source_Document_Nbr, CTE.Check_Nbr, 
CASE when prev.AvailableBalance is null then CTE.Available_Apply_Amount else prev.AvailableBalance end as Available_Apply_Amount,
              CTE.Apply_to_Document_Nbr, 
              CTE.CURTRXAM, 
              CTE.DOCDATE
, CASE when prev.AvailableBalance is null then 
CASE when CTE.Available_Apply_Amount < CTE.CURTRXAM then CTE.Available_Apply_Amount 
ELSE CTE.CURTRXAM 
END else prev.AvailableBalance 
END as Apply_Amount
FROM CTE
LEFT JOIN CTE prev ON prev.rownum = CTE.rownum - 1 AND CTE.Customer_Nbr = prev.Customer_Nbr
WHERE CASE WHEN prev.AvailableBalance is null then 
CASE WHEN CTE.Available_Apply_Amount < CTE.CURTRXAM then CTE.Available_Apply_Amount 
ELSE CTE.CURTRXAM 
END ELSE prev.AvailableBalance END <> 0

Suggestions on order/etc.?

SSMS 2017 cannot login to SQL server

$
0
0

I freshly installed SSMS 2017 17.9.1 I am trying to login to this server with SQL server Authentication and this error pops up . I tried SSMS 2016 it works, I tried SSMS 2017 on a different computer and it works. I had the admin double check to make sure my credentials are fine. I cannot find out why this error would happen on login. If someone could provide some solutions that would be great.

TITLE: Connect to Server
------------------------------

Cannot connect to bender.net.nait.ca,24680.

------------------------------
ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

------------------------------

An expression of non-boolean type specified in a context where a condition is expected, near 'dmc'.
Incorrect syntax near 'SmoEnabled'. (Microsoft SQL Server, Error: 4145)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=12.00.5207&EvtSrc=MSSQLServer&EvtID=4145&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

Support Life for SQL Server 2008 R2 Feature Pack

$
0
0

Hi, I'm trying to figure out the support life for SQL Server 2008 R2 Feature Pack and any pushes to the right direction would be greatly appreciated.

I have checked the site below but it only talks about the Service Pack and was wondering it this also included the Feature Packs. 

Would the Feature Pack supoort also end 07/09/2019? Any advice would be greatful.

<https://blogs.msdn.microsoft.com/sqlreleaseservices/end-of-mainstream-support-for-sql-server-2008-and-sql-server-2008-r2/>

Thank you in advance.

-Mari


Job runs but does not return any data in the Result set

$
0
0

Hi Folks,

I need some help here, I am trying to create a Replication monitor to view the Latency on a regular basis, the job runs but does . not contain any data in the result set email. This is the job I have created..


use master

go 
---------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
--Specify the email subject, @@servername will pick up replication distributor server name
---------------------------------------------------------------------------------------------
declare @mailsubject  varchar(100)
set @mailsubject = @@SERVERNAME + ' Replication Latency'

select datename(hh,GETDATE())

--if exists (
--select top 1 1  from sys.dm_os_performance_counters where object_name like '%Replica%' 
--and counter_name like '%Logreader:%latency%' and cntr_value > @threshold
--union
--select top 1 1  from sys.dm_os_performance_counters where object_name like '%Replica%' 
--and counter_name like '%Dist%latency%' and cntr_value > @threshold)
--begin 

DECLARE @tableHTML  NVARCHAR(MAX) ;

--DECLARE @xml NVARCHAR(MAX)
DECLARE @body NVARCHAR(MAX)

declare @minutes int, @threshold int
set @minutes = 30 --> Here is where you define how many minutes latency you would like to be notified
set @threshold = @minutes * 60 * 1000

SET @tableHTML =
--SET @xml =
    N'<H1>'+@@SERVERNAME+' Replication Latency</H1>' +
    N'<table border="1">' +
    N'<tr><th>Object Name</th><th>Counter Name</th>' +
    N'<th>Instance Name</th><th>latency in sec</th>' +
     ISNULL(CAST ( ( SELECT td = object_name,       '',
                    td = counter_name, '',
                    td = instance_name, '',
                    td = latency_sec, ''
             FROM 
             (select object_name, counter_name, instance_name, round(cntr_value/1000,0) as latency_sec from sys.dm_os_performance_counters where object_name like '%Replica%' 
                and counter_name like '%Logreader:%latency%' and cntr_value > @threshold
        union 
          select object_name, counter_name, instance_name, round(cntr_value/1000,0) as latency_sec from sys.dm_os_performance_counters where object_name like '%Replica%' 
                and counter_name like '%Dist%latency%' and cntr_value > @threshold) a
              FOR XML PATH('tr'), TYPE 
     ) AS NVARCHAR(MAX) ),'') +  
    N'</table>' ;

SET @body ='<html><body><H3>Replication Latency</H3>
<table border = 1> 
<tr>
 <th>Object Nane </th> <th> Counter Name </th> <th> Instance Name  </th> <th> latency in sec</th></tr>'    
--SET @body = @body + @xml +'</table></body></html>'
SET @body = @body + @tableHTML +'</table></body></html>'

  EXEC msdb.dbo.sp_send_dbmail
      @recipients='FB@skysports.com',  
      @subject = 'Replication Latency',  
      @profile_name = 'DBMail',
      @body = @tableHTML,  
      @body_format = 'HTML';

 

--  END

sa's password in SQL Server 2008 R2 Express

$
0
0
Hi,

In the SQL Server 2005 Express I can chose  the expert mode during the installation. This enables me to set the password  of the user “sa”.

Now I tried to install SQL Server 2008 R2 Express but I had no possibility to change / set the password of the user “sa”.

I read in the internet that the default-password of the user “sa” should be a blank password. Since in SQL Server 2008 R2 Express there was no way to set / change “sa”’s password I tried to login with a blank password. But this also didn’t worked.

So my questions are:

1.    Where during the SQL Server 2008 R2 Express setup can I set / change the “sa”’s password.
2.    Where in the SQL Server 2008 R2 Express can I set / change the “sa”’s password after the installation.
3.    What’s the default password of “sa” in SQL Server 2008 R2 Express?
4.    Why a blank password for the unmodified “sa” account didn’t worked? 

Thank in advance for all your helpful answers.

SQL Server in a box?

$
0
0

Hi all, 

I attended the MS Tech Summit in Sydney (Australia), and whilst there was given a little device that is supposedly a SQL Server in a USB device. It is a small white and black device and has Microsoft SQL Server written on the side of it. It has a black on\off button with 4 blue led lights on it. 

The issue is, I've never used it, and I cannot find the packaging or supporting information. I know it's a long shot, but does anyone know what this thing is called and or any supporting information. 

Cheers,

Adam.


Need help to open diagram in SSMS17

$
0
0

Hi! I am using SQL Server 2017 and SSMS17. When I try to open diagram , the SSMS will be "Not responding" mode and  restart!

What should I do with this error? 

Getting error while creating Log shipping

$
0
0

Primary Server - Connecting through Windows Server

Secondary Server - Connecting through SQL Server authentication

I am creating log shipping but getting below error

 

An exception occurred while executing a Transact-SQL statement or batch. (SqlManagerUI)

------------------------------

The volume on device <Network_Path> is empty.
RESTORE FILELIST is terminating abnormally. (Microsoft SQL Server, Error: 3254)



upgrading SQL 2014SP2 to SQL2016SP2 - But running Win2008R2 - How to?

$
0
0

upgrading SQL 2014SP2 to SQL2016SP2 - But running Win2008R2 - How to?

Now, I have a Win2008R2 OS, running SQL2014SP2 (recently we upgraded from SQL2008R2)

Now, the goal is to upgrade from SQL2014 to SQL2016, but Win2008R2 is not supported, am I right?

So.. how can I upgrade my Win2008R2 to Win2012--WIn2016?

May I just run the Win2012/2016 Setup and upgrade "on top"/"in-place", simply installing the new OS and keeping all data and configurations, as SQL Server upgrades does?

I´m thinking the same way SQL works, just installing a new SQL and keeping all data, may I do the same thing for OS?

Just run the upgrade proccess, upgrading Win2008 to the newer possible version, without changing hardware, without changing name? 




MS SQL Server Install error

$
0
0

I have a ThinkServer with an Intel Xeon E2-1226 v3 processor and 32 gigs of RAM running Windows Server 2016 Essentials.  I'm trying to set it up to run a simple web based forum and I'm attempting to install MS SQL Server 2017 Express.  I've done this installation successfully several times for almost two decades, starting with Windows Server 2000 on an Access back end, to a Windows Server 2008 with MS SQL Server 2014 and now to my newest server build.

I first attempted to install MS SQL Server 2014 Express and it failed trying to install the database engine.  After several failed attempts with the same result, I uninstalled 2014 and attempted to install MS SQL Server 2017 Express and I'm getting the same error no matter how many times I uninstall and reinstall.  If I don't uninstall and install another instance, the installation will be complete but then I have two instances running (SQLExpress and SQLExpress01).  While I could probably make this work, I'd like a single installation that works and I don't know why it will install as a second instance successfully but not a first.

Guidance would be appreciated.

Thanks,
Nathan in Montana


Nathan In Montana


Failed Restore

$
0
0

Hi Team

Hoping for a quick response here. I have backed up a SQL Database (MYOB) from Windows 7 Pro and exported this backup file to my new Windows 10 Pro machine.  However, when I try to restore the backup, it fails? I can verify the backup without any issues, but restoring it, it fails each time.

Any suggestions, as this should have been easy tasks.

Viewing all 8979 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>