Loading...
|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
The Original Database | |
In SQL Server 2017, what value does ORIGINAL_DB_NAME() return for a login? | |
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) |
Identity Values I have this query that I run in my database: SELECT SchemaName = OBJECT_SCHEMA_NAME(t.object_id, DB_ID()) , TableName = t.name , ColumnName = c.name , ic.last_value FROM sys.tables AS t INNER JOIN sys.columns AS c ON t.object_id = c.object_id INNER JOIN sys.identity_columns AS ic ON ic.column_id = c.column_id AND ic.object_id = c.object_id WHERE c.is_identity = 1;What does the ic.last_value represent? Answer: The last value used in an insert in this field from the identity property Explanation: The sys.identity_columns DMV contains the columns from sys.columns, but also includes other data about identity fields. The last_value is the last value inserted into the table. The next value is the last_value with the increment added to it. Ref: sys.identity_columns - https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-identity-columns-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 |
AG Listeners - multiple instances - Hi, I'm looking after a cluster that has 2 instances; one for 2016 and one for 2017. The AG listeners are both configured to use port 1433 and everything is working fine? Customer wants a separate instance of 2017 - how do listener ports relate to SQL ports? In the SQL port world named instances […] |
SQL Server 2016 - Development and T-SQL |
Datatype differences when restoring a database from one server to the next - Hello, I'm performing a backup/restore operation from a SQL Server 2012 database server to a SQL Server 2016 database server. The database is currently set to SQL Server 2008 compatibility within both database servers using the same 'SQL_Latin1_General_CP1_CI_AS' collation from the server level to column level. Now when the database finished restoring on the 2016 […] |
Roll multiple records into 1 - I'm trying to roll multiple records into one replacing null value. IF (SELECT OBJECT_ID('tempdb..#Table50'))is not null DROP TABLE #Table50 CREATE TABLE #Table50 ( MyID int, A int, B int, C int) INSERT INTO #Table50 ( MYID, A, B, C) SELECT 1, NULL,NULL, 53 UNION ALL SELECT 1, NULL,NULL, 54 UNION ALL SELECT 1, NULL,924, NULL […] |
SQL UniqueIdentifier question - Hello, Our reporting database truncates and loads latest data during each import and generates Unique Identifiers for Tasks and Project UIDs . Example: ProjectTable TaskTable We have a SharePoint list where incremental updates are done using TaskUID from Task Table and ProjectUID from Project Table. If with every refresh, Project and Task tables regenerates […] |
Extract string from string that contains specific first two characters - Hi I would like to extract from a full string the 'XX....' string. This specific string inst in the same position in my full string. - this string always starts with XX - this string always contains 6 characters thanks in advance, |
Administration - SQL Server 2014 |
Upgrading SQL 2014 to SQL 2017 cluster - Hi All, Not sure whether to post it here or in SQL 2017, but here goes.... We have a Win 2012 R2 / SQL 2014 cluster for a mission critical database. It's a 3 node cluster with nodes in different subnets. As DR we logship to a 4th off site server. We want to upgrade […] |
SQL Server 2012 - T-SQL |
View Dependencies - I have SQL Server 2012 and running the following query. THe results do not include all dependencies. I have a stored proc that calls a view, but that does notshwo up. How do I get full dependency list? SELECT ReferencingObjectType = o1.type, ReferencingObjectName = o1.type_desc, ReferencingObject = SCHEMA_NAME(o1.schema_id)+'.'+o1.name, ReferencedObject = SCHEMA_NAME(o2.schema_id)+'.'+ed.referenced_entity_name, ReferencedObjectType = o2.type, ReferencedObjectName […] |
SQL Server 2019 - Administration |
MIGRATE SQL 2014 to 2019 (not UPGRADE) - Anyone had experience migrating a SQL Server to the latest version? We have 2 servers, SQL 2014 SP3-CU4 + Windows Server 2012 R2 and would want to migrate both server to SQL 2019 + Windows Server 2016/2019. Have to point out the following: The servers has a transactional replication running. The subscriber server is also […] |
SQL Server installation with British English - What little hair I have left is being torn out in chunks trying to get to the right part of Microsoft to get a reasonable response, so I'm hoping you helpful lot here can answer my problem. When I try to install SQL Server 2019 and look at the instance properties, I see it has […] |
Availability groups and sql agent - I have A proof of concept 2019 sql server with 2 active nodes and a read only reporting node. I'm looking at the SQL agent jobs and don't want them to fire on both nodes - i know the jobs need to be on both nodes for a failover scenario so my plan was to […] |
SQL Server 2008 - General |
Continuously current list of attached files in SQL Server - This isn't strictly a SQL Server question, but there are some pretty sharp people on here, and I'm probably not the only one with a problem like this. I have a database that has associated files in a folder/subfolder structure on the server – Windows Server Standard, 2007, SP2. The associated files are mostly […] |
Integration Services |
SSIS Class not registered - Hello, I installed SSIS on a server by itself, it is 2016 version 13.0 version I followed permission directions from the link below: https://docs.microsoft.com/en-us/sql/integration-services/grant-permissions-to-integration-services-service?view=sql-server-2014 I tried to connect to SQL management studio version 16.3 version, to SSMS 18.4, and I get the following error message, I attached it. not sure why or what to do […] |
SQL Server 2005 General Discussion |
Attachments EMail - I'm having trouble trying to get my query results loaded into my excel attachment can anyone help. DECLARE @sub VARCHAR(100) DECLARE @qry VARCHAR(1000) DECLARE @msg VARCHAR(250) DECLARE @query NVARCHAR(1000) DECLARE @query_attachment_filename NVARCHAR(520) SELECT @sub = 'DC Weekly Transfer' SELECT @msg = 'This is Just a test.' SELECT @query_attachment_filename = 'dcweekly.csv' Declare @nOrgID int = […] |
my query results are not in my excell attachment can anyone help - Hello, I have a query here that is sending a excell attachment to a email the only problem is my results are not being put into that attachment also how do I distinguish this when I create a Agent Job what parts do I put where in my agent job. DECLARE @sub VARCHAR(100) DECLARE […] |
General |
Trying to Sum by different levels - Hello everyone, If any one could please help me with this? I'm trying to add additional sum by Family and Sum by Store level Trying to get this result It seem that i only know how to use group by at the end of my statement. |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Loading...
Loading...