How can I get the table name in a SQL Server trigger function? [closed] - sql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I tried to get the table name in a SQL Server trigger function but I can't.
Please help me.

Try this query for get the table name using trigger function:
#tablename = OBJECT_NAME(parent_object_id)
FROM sys.objects
WHERE sys.objects.name = OBJECT_NAME(##PROCID)**

Related

SQL Insert Query With Condition Exception [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I have this query:
String requete = "INSERT INTO reduction(newPrix) VALUES (?) "
+ "WHERE id_prom=? AND id_prod=?";
I am getting an exception:
You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use
near 'WHERE id_prom=2 AND id_prod=6' at line 1
I'm wondering why the INSERT query was failing. Any advise appreciated.
You insert a row into your table.
This means that you need to specify all mandatory values (i.e. values for the columns that are not nullable and don't have a default value).
You can't use a where clause in this kind of insert statement. What would it mean? And in your program you can verify the validity of the data you'd like to add to your table and decide to insert or not.

What is a clean way to copy a SQL table with more than 1000 rows? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I know the question "How to copy table with more than 1000 rows" is already asked. I have read a lot about it and the different solutions like:
use export to excel and than import in new table
use UNION ALL (but not recommend)
use bulkreader
export to file and import
etc.
All the solutions sounding like a workaround. I am asking myself, is there no "official", clean way to do it?
Thank you.
Edit:
SELECT INTO was tried
INSERT INTO was tried
Using sql MS MGM studio
using HeidiSQL
Working on a MS SQL Server 13.0.4001.0
The cleanest and fastest solution with T-SQL would be into:
select *
into [destination table]
from [source table]
This will copy your data into a [destination table]. Be mindful of the remarks and limitations in the documentation regarding this keyword.

How can I find the timezone of a SQL Server database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Is there an easy way to find the timezone for datetime dataype of SQL Server database?
You can use SYSDATETIMEOFFSET(). This will tell you the offset from GMT at the end.
SELECT SYSDATETIMEOFFSET()
2016-06-21 08:36:54.9753055 -04:00
Try this.
DECLARE #TimeZone VARCHAR(50)
EXEC MASTER.dbo.xp_regread 'HKEY_LOCAL_MACHINE',
'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',
'TimeZoneKeyName',#TimeZone OUT
SELECT #TimeZone

How to use sp_depends for other database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Using SQL Server 2010
For updating the tables i am using following line
update database1_ab..table1
For sp_depends i am getting error as "Incorrect syntax near '.'"
sp_depends database1_ab..table1
How to use sp_depends for referring other database tables in current database
regardless, you need to put it in single quotes... ie
sp_depends 'database1_ab..table1'
or
sp_depends '[database1_ab]..[table1]'
You can call all the sp_ -procedures also in different database like this:
database1_ab..sp_depends table1

Error message from simple SELECT statement with practice database [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I use the AdventureWorks practice database attached to SQL Server 2012.
A simple statement like:
SELECT * FROM HumanResources.Shift;
gives me this error:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'AdventureWorks2012'.
I also tried:
USE master
GO
SELECT * FROM HumanResources.Shift;
Received same error message. Any idea to why this is happening?
Is AdventureWorks2012 the name of a database or a table?
USE <database name>
means use the specified database to run the query against.
SELECT * FROM <table name>
means select all the rows from the specified table.
--Edit because of change in question--
You don't want to use Master, you want to use the name of your DB. Next, using the object explorer, I would make sure the table actually exists in the Database you created.