MySQL database stored procedure dynamic table creation (PREPARE)
PREPARE statement_name FROM SQL _text/* definition */
EXECUTE statement_name [USING variable [, variable...]/* EXECUTE preprocessing statement */
Deallocate prepare statement_name/* delete definition */This is used in my project for reference:DELIMITER $ drop
Label:Gooliugle inserting a stored procedure that updates the contents of a table SETAnsi_nulls on
GO
SETQuoted_identifier on
GO
-- =============================================
--Author:
--Create Date:
--Description:
-- =============================================
ALTER PROCEDURE [dbo].[Sp_propsreport_daysync]
Tags: ref tran Arch har nbsp Process use--openCREATE PROCEDURE [dbo]. [The name of the store-oh Procedure] @userID varchar (50)--Declaring variablesAsBEGINif (@userID = "OR @userID is NULL)--Determines whether the inputBEGINSelect ' 0 ' as ' message ', ' Please enter the user id! to delete ' As ' errorinfo '--hint informationRETURNEND Begin TRANSACTION--Open transaction DELETE from
Tags: mysql stored proceduresImplement a simple move table, using a cursor loopThe first line DELIMITER//and the last line//must, or encounter a semicolon to errordelimiter//createproceduremovedata () BEGIN DECLARE
doneintdefault0;
declarev_idvarchar (30); /* declaring cursors */declarers
CURSORFORSELECTidFROM ' new ' customer; /* Exception Handling */DECLARE
continuehandlerforsqlstate ' 02000 ' SETDone=1;
Recent projects have used the ability to build tables in bulk using stored procedures, which are documented: UseDb_test_3;Drop procedure if EXISTS' Createtableswithindex ';Create procedureCreatetableswithindex ()BEGIN DECLARE`@i`int( One); DECLARE`@createSql`VARCHAR(2560); DECLARE`@createIndexSql1`VARCHAR(2560); DECLARE`@createIndexSql2`VARCHAR(2560); DECLARE`@createIndexSql3`VARCHAR(2560); Set`@i`=
There are too many tables in the database. It is difficult to view the structure of a table, so it is easier to use this stored procedure;
CRM /* **************************************** **** Obtain table information based on the table name, including field descriptions.
The SQL Server Stored Procedure encountered the error "Table'' # TT ''cannot perform the SET operation without the identity attribute,
An error is reported when a temporary table is created and data is inserted into the temporary table.
The system prompts that the primar
Query Creation Time
-- TableSelect * From sysobjects where id = object_id (n'table name') and xtype = 'U'-- Table structureSelect * From syscolumns where id = object_id (N 'table name ')-- Stored ProcedureSelect * From sysobjects where id = object_id (n'stored procedure name') and xtype = 'P'
Query the last modifica
On the Internet, we can see that many people use links to delete recursive tables. But in sqlserver2005, I say that I am in violation of the constraints and depressed, so I want to use recursion. Here is a recursive table.
Create Table [DBO]. [Tiku] (
[Tikuid] [int] identity (1, 1) not null,
[Tikuname] [varchar] (50) Collate chinese_prc_ci_as not null,
[Tikuparentid] [int] not null,
Constraint [pk_tiku] pri
Server| stored Procedure--I refer to the table name my fruit some fields [5] to refer to some of the fields [3] in the following table [1]
DECLARE @id bigint
Select @id =id from sysobjects where name= ' d_ patient database '
Select a. Name n ' referenced table name ', B.rkey
In the project, you need to generate an Insert script for the data in the table, and find a stored procedure from the Internet. However, if an error is reported during execution, you can modify and debug it.
Added support for SQL keywords or space-based field names, while ignoring self-growth field data.
CREATE Procedure
Original address: http://blog.csdn.net/business122/article/details/7528859Today write a database to do a snapshot of the stored procedures, using the dynamic table name, suddenly found that MySQL does not support the direct use of variables to do the table name, Google down, using the following methods:DECLAREDbNameVARCHAR( -); SETDbName= 'AAA'; SET @STMT:=CONCAT
The stored procedure executes the select statement and the insert statement in the same table.
The stored procedure executes the select statement and the insert statement in the same table.Public void onedb_twoconnect (){Using (transactionscope scope = new transactionscope (
Ms SQL Server Stored Procedure batch modify user table owners
Create a login account and set login to the database to be modified.
Create storage process
Create procedure DBO. changename@ Oldowner as nvarchar (128), -- original parameter owner@ Newowner as nvarchar (128) -- New Parameter ownerAs
Declare @ name as n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.