Suljettu

T-SQL To Generate Select and Insert into scripts only for columns that have values

I have a script that will generate the Select statement for only columns that are not nullable. But, what I need is a script that will generate the Select and Insert into statements for only columns that have values in the table. That is because we always have dozens of columns that are not used. Database create script attached. Sql Server 2016

DECLARE @table nvarchar(261) = N'[dbo].[table1]';

;WITH x AS

(

SELECT name, system_type_name,

column_ordinal = ROW_NUMBER() OVER (ORDER BY column_ordinal)

FROM sys.dm_exec_describe_first_result_set(N'SELECT * FROM ' + @table, N'', 0)

WHERE is_nullable = 0

AND is_identity_column = 0

AND is_computed_column = 0

)

SELECT N'INSERT ' + @table + N'(', N'--', column_ordinal = 0

UNION ALL

SELECT CHAR(13) + CHAR(10) + CASE column_ordinal

WHEN 1 THEN N'' ELSE N',' END + QUOTENAME(name),

N'--', column_ordinal

FROM x

UNION ALL

SELECT N'

) VALUES (', N'--', 1000

UNION ALL

SELECT CHAR(13) + CHAR(10) + CASE column_ordinal

WHEN 1 THEN N'' ELSE N',' END

+ N'<' + name + N', ' +system_type_name + N',>',

N'--', 1000 + column_ordinal

FROM x

UNION ALL

SELECT N'

);', N'--', 10000

ORDER BY column_ordinal;

*/

/*

INSERT [dbo].[table1](

[IDNUM]

,[c1]

,[c2]

,[c3]

,[c7]

) VALUES (

<IDNUM, int,>

,<c1, varchar(9),>

,<c2, int,>

,<c3, int,>

,<c7, numeric(8,2),>

);

*/

Please reply with:

The time of day that you are available. I am available 7am to 10pm UTC-06:00 Central Time US & Canada. Will you require contact by voice and do you speak English? When you can complete the project.

Confidentiality.

a) No Use. Recipient agrees not to use the Confidential Information in any way, or to manufacture or test any product embodying Confidential Information, except for the purpose set forth above.

b) No Disclosure. Recipient agrees to use its best efforts to prevent and protect the Confidential Information, or any part thereof, from disclosure to any person other than Recipient's employees having a need for disclosure in connection with Recipient's authorized use of the Confidential Information.

c) Protection of Secrecy. Recipient agrees to take all steps reasonably necessary to protect the secrecy of the Confidential Information, and to prevent the Confidential Information from falling into the public domain or into the possession of unauthorized persons.

d) Scope. The scope of Confidentiality is deemed to be in all contracts present past and future with the Parties to this request

Taidot: SQL, Microsoft SQL Server, T-SQL (Transact Structures Query Language), Tietokannan hallinto

Tietoa asiakkaasta:
( 285 arvostelua ) SAN ANGELO, United States

Projektin tunnus: #34679649

12 freelanceria on tarjonnut keskimäärin $38 tähän työhön

(43 arvostelua)
5.7
Rahulkeshwani19

Hi, I can start working on right away and can deliver it in couple of hours and once you will get the result surely we will be having a long time business relation. Please open DM for further discussion, I have some qu Lisää

$65 USD 1 päivässä
(1 arvostelu)
4.4
freelancepraful

I can help you with sql server queries, please ping/connect me now I am available. Please check my reviews and project which I have completed. I can create sql queries for sql server database as per design, let me know Lisää

$10 USD 1 päivässä
(4 arvostelua)
4.3
bizmanas

Hi I have 15 years experience with sql server database development, mysql database development, performance tuning. I will be able to help you with the project. Please ping me offline to discuss further.

$150 USD 1 päivässä
(12 arvostelua)
4.4
eduardoherreral4

Greetings! I can help you with your project at a high level! I have lots of experience in SQL Server, T-SQL, SSMS. My skills and experience is a great match for your needs. Looking forward to hearing from you. Best r Lisää

$50 USD 1 päivässä
(5 arvostelua)
3.2
usamasohail91

Hi there, Good day,I have 6 years of experience in freelancer industry. I read your job description carefully I can provide you solid work in good time. Discuss on chat where I can easily share my explanation about you Lisää

$20 USD 1 päivässä
(0 arvostelua)
0.0
sametgj

^⭐Hi there⭐^., I am an experienced web developer. I have 7 years of experience and have strong knowledge inT-SQL. I have read the details of your project, I can definitely work for you as per your requirements. I am av Lisää

$20 USD 7 päivässä
(0 arvostelua)
0.0
jeetparekhnmims

Hi, I can help you with T-SQL scripts. I am available matching your time zone, 7am to 10pm. I can finish the task in a day. Also I dont think I require contact by voice, but if needed I do speak English.

$30 USD 1 päivässä
(0 arvostelua)
0.0
mannnupatel

I have more than 15 years of IT experience with various database technologies. Working Knowledge of Postgres,Oracle Databases. I have working experience in postgres database development as well as DBA. Expertise in d Lisää

$35 USD 2 päivässä
(0 arvostelua)
0.0
suyogdwabale

Hello, Hope you are good. So let's talk about the job. I gone through the job description and found you are going to modify the existing Scripts. My question is how many Scripts you want to modify? I am expert in writi Lisää

$20 USD 7 päivässä
(0 arvostelua)
0.0
CourserXu

Hello there, I have read your requirements and am confident I am the right candidate for the job. Among other things, I have over ten years of experience in Oracle PLSQL, PostgreSQL, MySQL, MS SQL, and others. Furtherm Lisää

$20 USD 7 päivässä
(1 arvostelu)
0.0
rguptatech

I can make changes to the script as required and available at the given time and I speak English. We can even do it faster if requirement is discussed further on call or msg.

$15 USD 4 päivässä
(0 arvostelua)
0.0