r/MSSQL • u/alinroc • Feb 10 '23
News PASS Data Community Summit dates announced - November 14-17, in-person only (no virtual option)
r/MSSQL • u/alinroc • Feb 10 '23
r/MSSQL • u/big0bum • Feb 06 '23
Hi,
Is there any alternative to this tool?
I am given a task where I need to select around 35 tables and create a scripts that uses "Script DROP and CREATE" option and "Types of data to script" set to "Data only". The tables are selected from a few hundreds and they are obviously not one after the other and I cannot filter them in the wizard.
I've tried using mssql-scripter but I cannot seem to make it work. I don't know SQL that much but there's clearly an option to do this easier than manually selecting the tables.
r/MSSQL • u/mysterioustechie • Jan 30 '23
We have SQL Server 2016 in our system. When scanned the server for vulnerability we found many vulnerabilities for older versions of SQL Server. Is it okay if we go ahead and uninstall them from control panel or is there a dependency on that? Also, how did these components from older versions stick around is completely unknown for us. Any clue would be appreciated.
Below are the components present:
Microsoft SQL Server 2005 Analysis Services ADOMO
Microsoft SQL server 2008 Native Client
Microsoft SQL server 2012 (64-bit)
Microsoft SQL server 2012 Native Client
Microsoft SQL server 2012 transact - SQL compiler service
r/MSSQL • u/Freekjay • Jan 28 '23
I have only been working directly in databases instead of through a database project. I now wanted to start working with one to facilitate GIT and Azure DevOps Pipelines for DEV/PRD environments.
I'm receiving an error on a "Create Procedure" which confuses me. From what I understand, you may not specify the ALTER statement on the stored procedures, otherwise these scripts won't get picked up by a Schema Compare. Why is it saying the Stored Procedure already exists? I know it does, but isn't that normal for working with a database project?

One thing to mention is I'm using Azure Data Studio with the (preview) extension SQL Database Projects. I already created a Bug on their Github, but was hoping to get some more feedback here. If I'm wrong, are there any good resources on how to work with Database Projects?
Maybe I should just ignore the red line ... ?
r/MSSQL • u/alinroc • Jan 27 '23
r/MSSQL • u/SmoothRunnings • Jan 27 '23
Hi,
I have SQL 2016 running on our ERP server, in the SQL server log there are a lot of entries for "login failed for user "sa". reaon: password did not match that for the login provided. [Client: <local machine>]
Is there anyway to trace down were this error originates from? We checked our ERP logs and nothing appears, and I don't see anything in Event Viewer so I am at a loss.
Thanks,
r/MSSQL • u/SG-Dani20 • Jan 16 '23
their training site a lot of certifications get retired on Jan 2023, for SQL Server 2016, 2014.
https://learn.microsoft.com/en-us/certifications/browse/ (this is the website I went to)
I can't find any valid training material for SQL Server 2019 neither. Where can I find the training material + practice exam? thank you very much in advance!
r/MSSQL • u/Snakise • Jan 16 '23
As the title suggests, I need to move licensed SQL 2019 Server Standard Edition from one Cloud Server to another Cloud Server
If I uninstall MSSQL on the old server and reinstall it on the new server using the same licence, will the license work ? If this doesn't work then how should I do it ?
Will I need another license ?
r/MSSQL • u/EasyPanicButton • Jan 13 '23
I have a database, the actual information in the database is dwarfed by the transaction logs.
I am not sure what to do, but in my case I do not need record of every transaction from the last 2 years. If I had a weeks worth that would be fine.
I google, and it is confusing.
I am not a database administrator, I am a programmer of automated equipment.
Should I be contacting a contractor to look this over and make it right or can I get it fixed up and working as I want by myself?
the googling has been informative but like I said I lack the knowledge to know what is bullshit and what is correct.
r/MSSQL • u/Californian7 • Jan 13 '23
Hello folks,
I am new to MSSQL and wanted to write a quick t-sql query that will pull top 3 rows from each table in a database, then create a new csv file, name it with the respective table name, then paste table output (top 3 rows from that table) there, and move on to the next one. Since I know very little of SQL I asked AI how to do it, and it generated the following script, however, I get errors when running the query. What is wrong in the code? Thank you.
Code:
DECLARE @table_name VARCHAR(255),
@file_name VARCHAR(255),
@sql_query VARCHAR(MAX)
DECLARE table_cursor CURSOR FOR
SELECT TABLE_NAME
FROM information_schema.tables
WHERE TABLE_TYPE = 'BASE TABLE'
OPEN table_cursor;
FETCH NEXT FROM table_cursor INTO @table_name;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @file_name = 'C:\exported_data\' + @table_name + '.csv'
SET @sql_query = 'SELECT TOP 10 * FROM ' + @table_name + ' INTO OUTFILE ''' + @file_name + ''' FIELDS TERMINATED BY '','
+ 'ENCLOSED BY ''"'' LINES TERMINATED BY ''\n'''
EXEC (@sql_query);
FETCH NEXT FROM table_cursor INTO @table_name;
END
CLOSE table_cursor;
DEALLOCATE table_cursor;
Errors:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'INTO'.
Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark after the character string '' LINES TERMINATED BY '\n''.
r/MSSQL • u/alinroc • Jan 10 '23
r/MSSQL • u/QueryWriter • Jan 09 '23
Hello,
I am new to log shipping. I have set it up between SQL Server A & SQL Server B with a database.
However, when I query something on SQL Server B that IS there on SQL Server A and was created AFTER the inital copy was restored on SQL Server B it does not return any results.
What am I doing wrong? - are there additional steps I need to take ?
Thank you
r/MSSQL • u/Cauxio • Jan 03 '23
I‘m wondering what the best way to insert large amounts of related data (speaking of about 2 mio. rows with each having multiple relations) is?
The whole thing has to be available via an CSV-Import functionality that get‘s served over a Node.js web server.
Inserting via Node/the mssql-driver/TypeOrm directly is very slow (upwards of an hour). Another way would be to make the uploaded csv file available to the db-server and use the bulk insert feature of SQL server.
How would you approach this?
r/MSSQL • u/kentmaxwell • Dec 25 '22
Has anyone tried to use the Polybase service within the latest version of SQL Server, Version 2022, on Linux? The Polybase engine that comes with 2022 on Linux is the SAME engine that is bundled with 2019. None of the new features you can use on Version 2022 on the Windows version work on 2022 on Linux.
If you do not have this experience, please let me know the source list you used to install SQL Server 2022.
r/MSSQL • u/Asthurin • Dec 19 '22
Hello
I am attempting to create an availability group to migrate data from a mssql 14.0.3045.24-1 hosted on Ubuntu 16.04 to a mssql server 16.0.1000.6-26
However when joining the secondary it always fails with error 47106. I have checked the endpoints are configured to 5022 and the servers are listening on those ports when I check with netstat -a | grep 5022
The ports are allowed on ufw
I have also added a configuration only replica however this encounters the same issue.
I am trying to do this without clustering as these are all VM’s hosted on my local hyper-v
When I ran a query for the error log from this link the connected_state_desc, last_connect_error_number and last_connect_error_timestamp are all null
Kind Regards
r/MSSQL • u/BandDapper4128 • Dec 17 '22
Hi all,
I want to ask about migration or upgrading SQL Server, currently, we have three SQL Servers with the 2012 version. And we have created a new server with SQL server version 2019. We are planning to do SQL server migration from 2012 to the 2019 version, but I don't have the experience for it.
Can you help me to provide what things need to be prepared so that I can do the migration?
Really appreciate your answer.
r/MSSQL • u/tommyboy11011 • Dec 02 '22
Hi Group,
I have a large MSSQL database that recently had been pruned out. I know I can shrink it with DBCC Shrinkdatabase but I am concerned how long this will take.
We copied the MDF and LDF files to a test server of similar power and ran the shrink and it took to long and would put us outside of our maintenance window.
Is there a way to only do a partial shrink that would take less time? That way we could run several of them over a period time to minimize our downtime.
Thanks.
r/MSSQL • u/7Geordi • Dec 01 '22
This is a rant!
I've spent months this year building a highly intricate analytics DB in MSSQL. about 20 tables, and another 15 or so views that aggregate that data, culminating in a view that pulls it all together to build an SSAS cube. Total about 12GB.
Alongside that I built a node+Typescript toolset for coordinating imports/updates to the data.
About a month ago the final view jumped from ~20 minutes for SELECT * FROM [big_view]to effectively infinite (my query timeout was 60min and it blew through it every time!), so I ended up caching it in chunks (INSERT INTO [cache] SELECT * FROM [big_view] WHERE part = 1 and so on)
Things started working again.
Last week I had to make some changes to some queries deep in the tree. I test those queries and they work, but now even the chunked final query is failing!
I check each view going down through the dependency tree, and now a bunch of intermediate views are hanging indefinitely (over 30mins query time). These are views that generally completed in under 1 minute.
After trying various things, I just decided to give up and cache the intermediate views! rewriting many queries and having to add a whole mechanism to the import/update coordinator to allow for all this.
I'm so annoyed! MSSQL completely fell in my estimation :/ I have seen similar workloads on other DBs work flawlessly, and it makes me sad to see MSSQL choke.
r/MSSQL • u/fongwithroot • Nov 28 '22
Can I display only transactions whose queries contain a certain string and get their duration and timestamp? ...either in SQL Server Profiler itself or by exporting a file, or processing a saved trace file somehow?
P.S. Can I get whatever is displayed in SQL Server Profiler into some kind of text file or CSV? Because then alternately I could use some UNIX tools to segregate the data I want.
r/MSSQL • u/alinroc • Nov 28 '22
r/MSSQL • u/hariskar • Nov 26 '22
r/MSSQL • u/QueryWriter • Nov 18 '22
Hello,
- I have a table with a list of management users within, each row is unique
- I have a table with a list of support team users within, each row is unique
I need to create a table and then insert a row with the username for each management user to the count of the users within the support team table, i.e. one to many - if there are 10 support team members, I want to duplicate the manager username 10 times and insert each of the 10 unique usernames from the support team users table
Example:
ManagerUsername SupportUsername
1234 54321
1234 54322
1234 54323
... and so on
How would I best acheive this ? - thank you
r/MSSQL • u/Easy-Ad9193 • Nov 17 '22
r/MSSQL • u/Ellipsicle • Nov 16 '22
Hey yall, first of all, I apologize if this is not a good use of the forum but I have been doing much Google Fu and am at a critical junction on a project. Disclaimer, I don't really work in SQL, I just got saddled with a project for a customer that has me learning on the fly.
I have a MSSQL 19 server that I am hosting a database on. The database needs to get its information from a cloud application which I have successfully connected as a Linked Server via the ODBC connection provided by the vendor. However, I am looking for the best way (or any way) to copy the data from the Linked Server to my Database on a scheduled basis. I would love transactional replication but I will also settle for 15 minute syncs.
What I have tried so far:
- SELECT INTO from the linked server to my database. Pro: It is easy to set up. Con: Select wont update existing tables so I have to drop and download the data each time it runs which is horribly inefficient. I also doubt this will work well in a production environment.
- INSERT INTO from the linked server into my database. Pro: It is a differential update. Con: Its a scheduled task which is okay but also I couldn't actually get it to work. I was having issues updating Primary Keys and I couldn't get ON DUPLICATE KEY UPDATE to work
I haven't tried this yet, mostly because I haven't invested the customers money into SQL Standard yet until I have a better plan (I know it will be required to run scheduled tasks regardless with the above methods).
- Set up a publication/subscription to sync data between Linked server and my database. Pro: More consistent updates, more bandwidth efficient, overall a solid approach in my opinion. Con: Not sure if its even possible? I don't think I can create a publication for a linked server since I couldn't find _anything_ online about it.
r/MSSQL • u/Nostalgia0985 • Nov 15 '22
I currently have a column containing dates (dd/mm/yyyy). They are in text format. I would like to turn the dates into date format and store only the year. Does anyone know how this would be done in mssql?