Quantcast
Channel: Microsoft SQL Server
Viewing all 4871 articles
Browse latest View live

SP to iterate over multiple tables, writing piped results to temp table

$
0
0

Requirement - I have to extract a lot of data out of our ERP database for prospective customer SARs under GDPR.

Assume the Temporary Table is something like the following:

SQL
createtable#GDPR_Temp(Customervarchar(12),Origin_TableVarchar(15),Datatext,Date_Readdatetime)

The Origin_Table field will be the table name queried.

The Data field will be the flat pipe-delimited text export of the data.

Example Origin Table:

SQL
selectrtrim(isnull(customer,'')),rtrim(isnull(address_ref,'')),rtrim(isnull(addr_desc,'')),rtrim(isnull(contact,'')),rtrim(isnull(title,'')),rtrim(isnull(initials,'')),rtrim(isnull(full_name,'')),rtrim(isnull(organisation,'')),rtrim(isnull(pobox,'')),rtrim(isnull(address,'')),rtrim(isnull(city,'')),rtrim(isnull(county,'')),rtrim(isnull(country,'')),rtrim(isnull(postcode,'')),rtrim(isnull(...

Question abouts Query vs. Insertion of data

$
0
0

Ok, this will be vague but here goes. I know what a query is. It is based on a SELECT statement. However, in general when I want to perform a calculation based on a select statement and have that result become part of the table data, what is the general framework? Here is an example.

I have a table named industry. There are 6 fields. The schema is given below. I know how to query and get results and then take those results to text files or excel. In this case, am needing to perform custom aggregations. There are 22 areas in the database. Needing to aggregate based on 17 of the 22. I can figure out how to aggregate using a select statement. Making it become additional rows to the industry table is where I need guidance.

create table industry
(
year char(4),
qtr char(2),
area char(6),
industry char(3),
ownership char(2),
employment numeric(8,0)
);...

How to write a query in SQL 2008 for last year same month comp numbers

$
0
0

I am looking for some help with writing a SQL query to return last years month to date sales numbers for a comparable to this year current months sales numbers.  I have tried everything and it is not working.  I can get my month to date sales numbers.  I just can't seem to figure the script out to give me the prior year month to date sales numbers.  Any assistance would be helpful.  I forgot to mention I need it to select the dates automatically.  I can get the numbers by using a simple query but I don't want to have to change the dates daily. 

SQL Studio hangs on "Executing" when changing backup model to simple

$
0
0

We need to change our SQL backup model to simple but when I do this through SQL Studio, it hangs on "executing" for hours. I have tried rebooting the server and when i try again, i get the same behavior.

Can anyone give me some advise on what may resolve this issue?

Bulk insert error: Bulk load: unexpected end of file

$
0
0

I am attempting a bulk insert of a fixed width text file. The text file is to be be broken up into 90 columns and each row is about 250 characters long. What I am looking for is a general explanation of this error. The data is quite confidential so I can't put up on here and it is rather long/cumbersome. However, if I can get an overall feel for it, I can better find the error. If it helps, I am trying to use a non-xml format file. There are two fields that are numeric but for now, I am leaving it as SQL CHAR. Could that be part of it?

Msg 4832, Level 16, State 1, Line 10
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 10
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line...

SQL server Express 2012 user limitation?

$
0
0

Hi,

Is there any limitation on how many users can access to SQL server express editions?

I think there is NO limits on users but I am not satisfied as I am not able to find any relevant document

Thanks 

Core licensing vSphere 6.5

$
0
0

Is there a best way to plan for SQL only ESXi hosts. There are approx 65 sql machines workload is the same. No OLTP involved. Half are in 5.5 and half in 6.5 vSphere. Mix of SQL 2003, 2005, 2008 and 2012. Windows machines are 2003,2008 and 2012. I’m unsure as to current physical core licencing would CPU and memory be the two biggest constraints. At back end SAN is being changed from VNX 5500 to Unity H. Just looking on how best to plan it we are hoping to use two hosts with cpu CPU E5-2690 v4 @ 2.60GHz and they are Lenovo physical servers.

Sage 300 / ACCPAC Application Slowness

$
0
0

At first this was thought to be a network issue, but seeing that Sage 300 takes ~10 seconds to get to the login screen on the server has me thinking it's a localized issue (My money is on SQL delaying queries). Also seeing delays when running standard queries within the application.

End users are seeing ~2+ seconds more of a delay compared to running the application on the server.

As for server specs, we're looking at roughly 10 times what we're needing...and still seeing the latency occur (SSD's, 10Gbs pipe, over 50GB RAM, plenty of memory available). Not a single resource is ever approaching 30%. Full 1000Mbps backbone.

- Tested the application with our AV completely disabled, no difference. Running on a 2016 VM <1yr old Hyper V host.

- The only resource waits showing on the SQL DB are showing 800-1000ms on the Network I/O (Yet we see the local application...

1yr>

Need to modify simple (existing) Transact-SQL SQL backup command

$
0
0

We manage a server for client A. Client A uses a product from Third Party B. We work with Third Party B, but they can occasionally be a little difficult to deal with.

One problem with Party B is that we have talked with them about not having a scheduled backup of their SQL database on Server FOO that backs up to the C: drive. This produces a 90GB backup file, blowing up the drive space, and causing problems blowing up our own volume image backup. Party B when we discuss with them gets cranky, insists we should just give them more disk space on C:, and then basically says "You sort it out, do it your way, but your blood be on your own head if it causes problems for the client." I don't think they really know SQL much, just the product that uses the SQL database, so I've tried to show them the maintenance plans I created to backup the...

How to allow multiple users access to a SQL server

$
0
0

I have a SQL server that hosts an accounting software, I need to be able to allow up to three people to access the software at once, I am wondering what that would look like?

Thanks, 

MS SQL backup error 0x80090006

$
0
0

Here is the following backup error that happens when SQL server does a Full Backup. Differential Backups work without issue. Any help with how to fix would be appreciated 

Here is the error

BackupIoRequest::ReportIoError: write failure on backup device '\\backup path'. Operating system error 0x80090006(Invalid Signature.).

Export from VarBinary

$
0
0

Hi Guys

Please bear with me as I dont have very much SQL knowledge.

I am trying to help out a friend who has a lot of .doc and .rtf files in a SQL DB in varbinary format.

He wants to get the docs out but only those from the last 3 years, the table does have a createdon field. it also has a file extension field. 

I have done a bit of research and it seems possible but my lack of background is not helping me decipher the SQL needed to do this. I think i may be able to use BCP? any suggestions gratefully received.

Thanks :)

sp_send_dbmail issues

$
0
0

I seem to be having an issue with sending DB mail.

I have successfully set up my profile and account, and the test email was received.

However for some reason I can not get any mail to send using sp_send_dbmail. It probably comes down to the fact I may have overcomplicated some of the email content creation, so that staff can edit the email templates once I had everything set up. Because of this, I'm going to explain the full process so I don't miss anything that may be causing the issue.

The system is a recruitment/new starter tracking system. The first email I am trying to set up is a contract request email.

Because I wanted the staff to be able to edit the email templates in a similar way to a mail merge uses merge fields, I started off by creating a lookup table which listed the fields and their corresponding "tags" to be used...

Conversion failed when converting the varchar value to data type int

$
0
0

Hello,

Running out of ideas how to fix this case. I am getting  an error: Error converting data type varchar to numeric.

      CASE
        WHEN sopHdr.SOPTYPE = 4
        THEN CONVERT(int,(sopHdr.DOCAMNT - inv.TaxTotal) - CONVERT(int, inv.CostTotal)) * - 1 * CONVERT(int,proj.UserText1) / 100.0
                    ELSE CONVERT(int,(sopHdr.DOCAMNT - inv.TaxTotal) - inv.CostTotal) * CONVERT(int,proj.UserText1) / 100.0
        END

Please help.

Conversion failed when converting date and/or time from character string

$
0
0

Have the code below but i am getting an error message. The error message is "Msg 241, Level 16, State 1, Line 2 conversion failed when converting date and/or time from character string.

Can I get help from someone?

select

UAMicroDate=max(Case
When (convert(datetime,cast(lab.CollDate as varchar(255)),101)cast('1901-01-01' as varchar(255)) and
convert(datetime,cast(lab.CollDate as varchar(255)),101) is not null) Then 'Collection Date'
When (convert(datetime,cast(lab.ResultDate as varchar(255)),101) cast('1901-01-01' as varchar(255)) and
convert(datetime,cast(lab.ResultDate as varchar(255)),101) is not null)
Then 'Result Date' Else convert(datetime,cast(isnull(enc.date, 0)as varchar(255)),101) End),
enc.date, datecheck=ISDATE(enc.date),

enc.patientid pid

from labdata lab

inner join labdatadetail result on result.reportid=lab.reportid
inner join...


Can I Make an Ad Hoc SQL Script That Utilizes CLR?

$
0
0

Our core software is an IIS/.net app with a SQL backend.  Every so often we need to copy that DB to our test environment.  I had a script that performs a number of functions, one of which is hashing a string that gets inserted into a password field on the customer records.  

The vendor has changed the storage method and hashing process.  The only option I have available is to use some CLR functions for the task.  My script though, is just something I rung from the SSMS query editor.  

Can I call CLR functions from there?  Do I have to enclose it all in a stored procedure and call the CLR component from a file?  I've found a couple of tutorials, but all refer to an external location rather than something I can drop into my query editor.

How best to deduplicate a table in SQL

$
0
0

I have a table in this instance titled industryimport. It is formed by using a merge statement and combining 8 other tables into one. I have failed to find a way to de-duplicate using union of the 8. So once industryimport is formed, is there a way to de-duplicate based on all 22 columns/fields being identical. There is a compound primary key composed of 9 fields and 13 foreign keys, if that is of any relevance. Just Just looking for some basic conceptual to get started. 

Cannot create sql instances using domain accounts

$
0
0

Hello there,

I am new server analyst not familiar much with sql servers. I want to help our DBAs who are telling me that they are unable to create Solarwinds SQL DPA Database instances using domain account.

I am aware is that it’s sql 2016 server.

Domain user does not work but sql server login works to create instances.

These domain accounts that they are trying to create instances with are added as Local admin on this sql server already.

Can someone point me in right direction on how to make these DBA guys able to create instances using domain accounts ?

Thanks in advance !!

RUN .dtsx package with config file

$
0
0
First let me start out by stating for security purposes, we can not have Linked (SQL servers-2008R2. We can not have access to use OPENQUERY or OPENROWSET.We can't have SSIS.
We have 2 SQLServers with identical databases. One is Production. One is test. The originators decided to refresh the test database using DSN and access VBA queries.
Mainly because IT dept takes forever to give us a restore into test and also not all tables are needed to be fefreshed. About 90% get refreshed.
Just basically first delete the tables from the test data base and run the queries on the Access app thatselect/ Insert from the production server to the test database.
Very simple. It took about 4 hours. Well now the testserver has been moved offsite. It takes about 16 hours or more. I understand that Access is doing all the work this way.

I used the...

SQL Maintenance plan stopped backing up translogs

$
0
0

In the last month, I've moved a bunch of SQL Server maintenance plans over to a new server. Upon doing so, I've went into each maintenance plan and updated accordingly. All works well, except for the trans logs, the job fails every time. This is happening on two servers: Srv 2008 & 2012

When I go to the log file viewer, the error message shows that the failure is due to "The system cannot find the file specified" and I can see it's trying to write to the old server from the Transact-SQL command.... 

Does anybody know how to resolve this?

Viewing all 4871 articles
Browse latest View live


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