|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Reseed Locks | |
I need to reseed a table with this code:
DBCC CHECKIDENT('Status', RESEED, 100)I am concerned about blocking and locking in this database. What locks will this code take on my table? | |
Think you know the answer? Click here, and find out if you are right. |
Yesterday's Question of the Day (by Steve Jones - SSC Editor) |
The Best Query I have a table full of various candies. CREATE TABLE Candy ( CandyName VARCHAR(100) , CountryName VARCHAR(50) ) GO INSERT dbo.Candy (CandyName, CountryName) VALUES ('Meiji Kinoko no Yama', 'Japan'), ('Shokolad Para Pitzputzim', 'Israel'), ('Guayabitas', 'Costa Rica'), ('Caramello koalas', 'Australia'), ('Marabou Mjolkchoklad', 'Sweden'), ('Ptasie Mleczko', 'Poland'), ('Coffee Crisp', 'Canada'), ('Saft Goldbären', 'Germany'), ('Nestle Damak', 'Turkey'), ('Indy Dedos', 'Mexico'), ('Fazer''s Marianne', 'Finland'), ('Pascal Pineapple Lumps', 'New Zealand'), ('Percy Pig gummies', 'United Kingdom'), ('Salmiakki', 'Denmark'), ('Dorina Riža', 'Croatia'), ('Strawberry Kiss Yupi', 'Indonesia'), ('Regina', 'Portugal'), ('Mozart Kugeln', 'Austria'), ('ION', 'Greece'), ('Kinder Bueno', 'Italy') GO I have another table for pranks. CREATE TABLE Prank (PrankName VARCHAR(200)) GO INSERT dbo.Prank (PrankName) VALUES ('Give out a burger that looks like a cupcake'), ('Gift wrap a rock'), ('Shoot silly string'), ('Play recording of dog attacking the door'), ('Drop balloons from upper window'), ('Give out resume paper and pens'), ('Drop slime into their hand'), ('Turn out all lights') GO I run this code to decide whether to give out a trick or treat to each person that comes to my door. How many people can I serve on Halloween night? SELECT CASE WHEN RAND(CHECKSUM(NEWID())) > .5 THEN c.CandyName ELSE p.PrankName END FROM dbo.Candy AS c CROSS JOIN dbo.Prank AS p; Answer: 160 Explanation: There are 20 rows of candy and 8 pranks. A cross join gives me 160 rows. Happy Halloween!!! Ref: FROM - https://docs.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql?view=sql-server-ver15 |
Database Pros Who Need Your Help |
Here's a few of the new posts today on the forums. To see more, visit the forums. |
SQL Server 2017 - Administration |
Index question - We have some indexes we have changed over the last few years to address performance problems. Currently the system is in MySql. But we are planning to do the migration to SQL Server. Not any issues in MySQL. I am thinking of making the changes in SQL Server. Let me know what you think? |
Process to failback after an AG failover using asynchronous mode - I'm testing the failover process in my AG that is using Asynchronous availability mode. In the scenario where I manually failover from Server A (primary) to B, what is the process to fail back to A? It seems like the only way is to rebuild the entire synchronization from B to A, failover to A, […] |
SSIS 2017 stopped running, not status is Pending Execution - We have 3 sql agent jobs that are running SSIS packages. Until this past Saturday these have been running wonderfully. However, now they stop with a Pending Execution status. Even if I just run the SSIS alone it gives the same status. I have restarted the services. Restarted the server. Made sure SSIS and SQL […] |
SQL Server 2017 - Development |
Stored Proc with OPENJSON: How to determine insert or update? - This is my 1st attempt at openjson & I'm trying to setup a stored proc that passes in multiple records and either inserts or updates the record in the table. I can setup the basic insert or update query using my openjson, however I don't know how to determine if the current record needs to […] |
Question about Data Warehouse - Hello. I just rejoined SQL Server Central. I'm here because I'm a solo reports developer for a small business. I use SSRS, Tableau and QlikSense to develop reports and dashboards. I also write complex stored procedures to produce the datasets that I need. These Forums are the only places where I can ask questions or […] |
SQL Server 2016 - Administration |
Login to SQL Server cross domain AD Group user - Our MS SQL Server is on another trusted domain (Trusted Domain T). We created a Universal Group within Domain A with users from different forest domains and added the AD group onto the SQL Server. When the user from Child Domain B tries to connect, they get the error: "Login failed for user". If I […] |
SQL Server 2016 - Development and T-SQL |
table variable - deleted code resolved issue |
product version result - SELECT SERVERPROPERTY ('ProductVersion') Output: 13.0.4001.0 What does each of those numbers mean.I need to find the most recent hotfixes applied on a server. Is 4001 the most recent hotfix applied 13 signifies sql 2016 First '0' is it sp1 ?? And what the last '0' signify ? SELECT substring(SERVERPROPERTY ('ProductVersion'),6,4)..this results in an error . […] |
Help Writing a Udf that get Number of "Years in a row" - Hello. I have a table (say orderlines) with orderrows, There is a column that holds the "Year" of the orderline. I like to write a userdefine function that calculate how many years in a row that item has been sold from today and back. For examle : If I in the table have: […] |
Trying to get a arithmetic operation from an Variable - Hi, I am not sure if this can be done, but I seem to remember there is some format thing that can be done with quates. Thant would pull out the value so that I can use it in something like this: Declare @dd Varchar(2) = '<' SELECT *FROM SalesWhere [sale_id] + @dd + 2 […] |
Administration - SQL Server 2014 |
Cannot remove growth restriction from log files - I have an instance where I have sysadmins. There a number of databases created by users and also msdb where I am unable to set log file growth to unlimited. It seems that when I change the setting all is OK but on checking back it has reverted to limited. I have altered the setting […] |
SQL 2012 - General |
'xp_sqlagent_notify' error on job run - Recently, our corporate office forced us to downgrade some non-prod servers from enterprise edition to dev (don't ask, long story). We did so, but now our QA team is having some problems running jobs on the servers. More specifically, a job set up by a vendor to backup & restore a database from server A […] |
SQL Server 2019 - Development |
Getting the top unique value by group - Alright, so I've been banging my head against the wall for a bit on this one, trying to avoid my developers going RBAR. We have two tables, and are trying to populate a third table by selecting the first available processing number for each ID. The two tables are joined like this: TABLE1.ID Table2.Processingnumber 1234 […] |
Integration Services |
SSIS projects connection manager driver - Hi I am starting using the project deployment mode. I am using SQL server 2019 And I see when I add a connection in connection manager for a package, I cannot see the sql server native client driver any more. What connection manager type do you recommend for SQL server connections? Thanks |
Business Intelligence |
cannot find MSOLEDBSQL driver for SSIS 2019 connection manager - In the list of connection manager driver, I cannot find MSOLEDBSQL, There is a microsoft OLEDB for SQL server, but that is SQLOLEDB, as the online doc says both SQLOLEDB and SQLNCLI native client will be deprecated. For new development use MSOLEDBSQL, but I cannot that driver in the list when I create new connection […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |