Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove angle brackets and data types from sql query from the values fields in sql server

Tags:

sql-server

i want to generate insert query from the sql server from table . but im getting some unwanted code in sql query . how to trim or remove brackets and data type values. is there any short cut method to write insert query from the table

INSERT INTO [dbo].[tbl_invoice]
           ([Id]
           ,[InvoiceNo]
           ,[InvoiceNoDated]
           ,[DeliveryNote]
           ,[Despatch Doc. No]
           ,[DespatchDated]
           ,[termsofdelivery]
           ,[ItemCodeandDescription]
           ,[quantity]
           ,[unitprice]
           ,[totalpriceexcludingtax]
           ,[taxPrice]
           ,[TotalPriceIncludingTax]
           ,[GrandTotal])
     VALUES
           (<Id, int,>
           ,<InvoiceNo, varchar(50),>
           ,<InvoiceNoDated, varchar(50),>
           ,<DeliveryNote, varchar(max),>
           ,<Despatch Doc. No, varchar(50),>
           ,<DespatchDated, varchar(50),>
           ,<termsofdelivery, varchar(50),>
           ,<ItemCodeandDescription, varchar(max),>
           ,<quantity, int,>
           ,<unitprice, varchar(50),>
           ,<totalpriceexcludingtax, varchar(50),>
           ,<taxPrice, varchar(50),>
           ,<TotalPriceIncludingTax, varchar(50),>
           ,<GrandTotal, varchar(50),>)
GO
like image 238
krishna mohan Avatar asked Jun 12 '26 18:06

krishna mohan


1 Answers

Both SSMS (where I'd imagine you're getting this from) and Visual Studio have, for quite some time, supported Find & Replace with regular expressions.

A Find & Replace specifying \<[^\>]+\> as the Find Text, using the Regular Expressions Find Option, and specifying an empty string as the Replace Text should quickly sort this out.

Unfortunately, there's no option to prevent SSMS from generating these template parameters. Most people find them a useful reminder, at times, of the required data types, and it's usually quite quick to just highlight each one before typing the replacement value you want.

like image 164
Damien_The_Unbeliever Avatar answered Jun 14 '26 08:06

Damien_The_Unbeliever



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!