Alibabacloud.com offers a wide variety of articles about select stored procedure into temp table, easily find your select stored procedure into temp table information here online.
Creates a temporary table that reports errors when inserting data into a temporary table.
A start prompt does not open the primary key, and then the primary key is turned on to prompt the above error exception.
Find information from the Internet did not find, and then to the group to ask you Daniel, a Daniel told me is not set the primary key.
I took a closer look at the hint and realized that I had se
Direct error reporting without using dynamic statements
IncorrectCopy codeThe Code is as follows: alter proc testpapersAsBeginDeclare @ tems nvarchar (max), @ zidaun nvarchar (max)Set @ tems = select * from @ tems order by @ zidaunExec (@ tems)EndExec testpapers
Message 156, Level 15, status 1, process testpapers, 1st rowsThere is a syntax error near the keyword 'select.Message 1087, Level 15, status 2, process testpapers, 1st rowsThe
I think everyone has this experience in the project. A stored procedure has a large number of parameters, and a large number of repeated parameters must be written when writing a function.
Code And switch back and forth between SQL and vs to view the parameters. The same is true for data tables. Therefore, we have written two templates to accelerate development efficiency, the template can be used with sli
--Query establishment time
--table
select * from sysobjects where id=object_id (N ' table name ') and xtype= ' U '
--table's structure
select * FROM syscolumns where id=object_id (n ' table name ')
--Stored
Label:Tools to use:
Sql server
Java
MyBatis
First step: Create a function to get the data in the XMLCREATE function create_table (@str XML) returns @tb table (SourceID varchar) asbegin INSERT INTO @tb SELECT v.value (' @sourceId [1] ', ' VARCHAR ') as SourceIDfrom @str. Nodes ('/ Rsssources/rsssource ') x (v) return endStep two: Create a
Label:Original: SQL Server uses RowNumber () built-in functions with the over keyword to implement a common paging stored procedure (support for single-or multiple-table node-search-Sets paging)SQL Server uses the RowNumber () built-in function with the over keyword to implement a common paging stored
A. rename a table
Rename the table oldtablename to newtablename:
Exec sp_rename 'oldtablename', 'newtablename'
B. rename a columnRename the column oldname in table 1 to newname.Exec sp_rename 'table1. oldname', 'newname', 'column'
Note: Table 1 is not added before newname.
Determining columns and determining
Direct error reporting without using dynamic statementsIncorrectCopy codeThe Code is as follows:Alter proc testpapersAsBeginDeclare @ tems nvarchar (max), @ zidaun nvarchar (max)Set @ tems = select * from @ tems order by @ zidaunExec (@ tems)EndExec testpapers Message 156, Level 15, status 1, process testpapers, 1st rowsThere is a syntax error near the keyword 'select.Message 1087, Level 15, status 2, process testpapers, 1st rowsThe
Stored Procedures | data | statements
There is a drawback ... Is that the column that identifies the seed is also insert.
CREATE proc Spgeninsertsql (@tablename varchar (256))
As
Begin
DECLARE @sql varchar (8000)
DECLARE @sqlValues varchar (8000)
Set @sql = ' ('
Set @sqlValues = ' VALUES (' + '
Select @sqlValues = @sqlValues + cols + ' + ', ' + ', @sql = @sql + ' [' + name + '], '
From
(
SQL Server:Declare @ name varchar (30 );Declare my_cursor scroll cursor for select productname from kuailegu. tb_product;Open my_cursor;Fetch my_cursor into @ name;While (@ fetch_status = 0)BeginFetch next from my_cursor into @ name;Print @ name;EndClose my_cursorDeallocate my_cursor
Oracle version:DeclareCursor getrecord is select name from table;Myname vachar2
Tags: bulk PHP Comment Prepare class creates mysq $$ com100 tables were created because of business needs, but the structure of these tables is the same, and as programmers, it is to solve this repetitive work. However, this kind of thing to write a PHP script alone is too much trouble, so I simply learned how to do it directly with the MySQL stored procedure:The first is to create the table: (Lpad (' @i ',
General traffic is larger than the Web site, and the request log table is created independently of one table per day. The business needs to add a new column for each table, and for half a day, write a stored procedure like this:Log table
2nd part Database SQL languagePreservation of important table information in database stored procedure and related suggestions1. Saving important table information in the stored procedureIn many stored procedures, it involves upda
Typically, a single-day log records only the log information for the day, and if you need to see the log information within a month, you need to stitch the daily log table result collection, usually with union.Storage process:Drop PROCEDURE if EXISTS unionsp;delimiter//create PROCEDURE unionsp (stime varchar (+), etime varchar (+), Tchema varchar (+)) begindecla
SqlPager Stored Procedures
Copy Code code as follows:
ALTER proc [dbo]. [SqlPager]
(
@tblName varchar (255),--Table name (Note: You can link multiple tables)
@strGetFields varchar (1000) = ' * ',--columns to be returned
@OrderfldName varchar (255) = ',--sorted field name
@PageSize int = 10,--page size
@PageIndex int = 1,--page number
@doCount int = 1 output,--number of records queried
@
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.