|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Cross Database Context | |
I set my context in DatabaseA with this code:
SET CONTEXT_INFO 0x1256698456;If I change the same connection to DatabaseB, what does this code return? SELECT CONTEXT_INFO(); | |
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) |
Dropping Columns I have a table in a SQL Server 2017 database that looks like this: CREATE TABLE ArticleSeries ( SeriesID INT NOT NULL, ArticleID INT NOT NULL, ArticleOrder TINYINT NOT NULL, ArticleAbstract VARCHAR(200), ArticlePublishDate DATE ) GO I have decided the ArticleAbstract and ArticlePublishDate can be removed as they are stored in another table. Can I delete them like this or do I need two batches? ALTER TABLE dbo.ArticleSeries DROP COLUMN ArticleAbstract, ArticlePublishDate GO Answer: Yes, of course you can Explanation: You can delete multiple columns in the DROP COLUMN phrase. Ref: Drop a column or columns - https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql?view=sql-server-ver16#Drop |
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 |
slow performing query - Hi All, I am seeing a lot of page splits happening on this table. A lots INSERTS and DELETES happens on this table. Its a very high transactional table. A lot of concurrent operations happens on this table. Is there anything can be done to fix at table level to avoid page splits? CREATE TABLE […] |
SQL Server 2017 - Development |
How to delete all records if sub query returns no records/values - Good Morning, I have a quick Question Have a table called subtable with column Year(YYYY) format number. so I am doing DELETE FROM ORDERS WHERE YEAR(ORDER_DATE) IN (SELECT YEAR_YYYY FROM subtable) ---> this will do what I need. the quetion I have is How to delete all if the subquery returns no rows. in other […] |
SQL Server 2016 - Administration |
Multiple Mirroring Entries in Mirroring Monitor for the same DB - Hi there, I just wanted peoples opinion on what I've seen in the Mirroring Monitor. We are encountering a few odd issues where dotnet app seem to intermittently try to connect to our DR DB. Naturally we gone through all of our connections strings. Our current thinking is that sometimes the mirror server is not […] |
SSRS folder permissions do not propagate - Hey everyone, I've come across something very strange that I cannot explain in the SSRS web page for SSRS 2016. I have created a folder called "Scheduled Reports" that contains some reports. Recently, I needed to give a user access to them; so I went to the Home folder and gave Domain Users the Browser […] |
SQL Server 2016 - Development and T-SQL |
How to pull Year from varchar field - Hello, I have a field where I want to pull the year from. The field unfortunately is an "Intelligent field" and the year is in the middle. For example, the format is text - year - text. Is there a way I can extract the year from the field? Here is some sample code: CREATE […] |
Get value after certain characters - Hello! I have a column with this data: A~B~C How would I just get the last value "C" select left('A~B~C.ab', LEN('A~B~C.ab') - CHARINDEX('\', REVERSE('A~B~C.ab')) + 1),RIGHT('A~B~C.ab', CHARINDEX('\', REVERSE('A~B~C.ab')) - 1) I am using this and getting Invalid length parameter passed to the right function. Thanks. |
Writing a line for each day of month??? - I'm looking to write a record or each day of a month(or date range) I have a query that gets a name, and ID and write it to a temp table I'd like to generate output with record for each date in the date range example I write a temp table with JimJames 901111 Marymaples […] |
How to import data from HTML file or page? - Hi all, So I have this html page: https://ofsistorage.blob.core.windows.net/publishlive/2022format/ConList.html On this page there is data that looks like this: I want to import this data to my SQL tables using SSIS or SQL queries. What tasks or queries I can use to complete the import process? Regards |
Development - SQL Server 2014 |
SQL Performance - I have a poorly performing proc, that is called heavily, and is taking around 4 seconds to complete. I have tuned the worst performing statement, and it appears to be a good improvement. HOWEVER, the elapsed_time from sys.dm_exec_query_stats is degraded. The question is whether my efforts have been successful or not? Any thoughts would be […] |
SQL Server 2019 - Administration |
extended property - We would like to create a data dictionary for our SQL database, with some description for table and columns. As I understand it can be stored in extended property for the table and columns, then we can pull from it. Is there any bad effects for adding extended property to columns and tables Othan than […] |
Pre staging Listener for AG - Hi I'd like to be able to pre-stage AG Listener object using PowerShell. I want to apply the granular permissions to it instead of giving the Cluster Object full control. This means assigning the cluster object the below permissions in Active directory. Does anyone have any PowerShell to do this. I'm sure I used to […] |
Certificate on database servers - We have about 40 SQL database servers in our organization. They are all behind firewall, and most of them for our intranet applications. And a couple of them as a database backend for our public websites. We don't configure these SQL servers to use certificate. Recently our developers upgraded frontend application's .net framework from […] |
SQL Server 2019 - Development |
How to Extract a Substring From a String in T-SQL - Hi SQL Team, May I know how to get the 'ABC123_Clm R' string from the following string in SQL Server? Many thanks. /Opr Rep/Clm R/ABC123_Clm R |
SQL Azure - Administration |
Linked server - I created linked server from Azure to On prem and when i do a test connection it fails Named pipes provide could not open a connection to SQL server OLEDB provider MSOLEDB for linked server returned message login timeout expired. a network or instance specific error occurred while establishing a connection to sql server. server […] |
Amazon AWS and other cloud vendors |
SAM CLI directory packaging capabilities - Hello! I was simply wondering if when trying to use the SAM cli to create and package lambdas, is there a way to include multiple files not actually related to the lambda handler/body at all? For example could I include a directory of different code with the packaged Lambda? |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |